Today I started working on: https://github.com/HearstAT/ensemble

I wanted to start off right by debugging in a docker container as I blogged about recently.

NOTE: this is much more a stream of consciousness than the last post. Mostly I am focusing on the issues/resolutions I encountered along the way and may clean up at another time.

So I moved over the files from my ruby_docker_breakpoint example for Sinatra.

  • Dockerfile
  • docker-compose.yml
  • .vscode/launch.json

I updated the obvious stuff (changing out 4567 for 3000).

I am still running into that the ruby2.3 docker image will not work for the same reasons, so I am using ruby2.2.

I ran into issues locally when trying to install ruby 2.2.x using rvm rvm install 2.2:

dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
Referenced from: /usr/local/bin/bash
Reason: image not found

Which landed me here: https://github.com/Homebrew/homebrew-core/issues/5799 So locally I ran:

brew update
brew doctor
brew upgrade bash
# this brought me to bash 4.4.5
rvm get stable
# this brought me to rvm-1.27.0
# why not update everything
brew outdated
brew upgrade

This brought me from git 2.6.1 to git 2.11.0 Then I ran into this a bunch: http://stackoverflow.com/questions/33636467/unable-to-click-always-allow-on-git-credential-osxkeychain-popup Eventually removed git credentials from keychain and need to come back to this to clean up so I do not have to put in credentials all the time.

Then I installed ruby 2.2.x and 2.3.x locally

rvm install 2.2
# which gave me ruby-2.2.4
rvm install 2.3.3

Here I fidgeted with both 2.2.4 (Rails needs a minimum of 2.2.2 currently based on the documentation)

I eventually landed on that I will be able to run ruby 2.3.x locally even though I am constained back to ruby 2.2.x in the docker container.

So now on to the:

docker-compose build
docker-compose up

First error was:

➜  ensemble docker-compose up   
Recreating ensemble_hellorubyvscode_1
Attaching to ensemble_hellorubyvscode_1
hellorubyvscode_1  | Bundler::GemNotFound: Your bundle is locked to rake (12.0.0), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of rake (12.0.0) has removed it. You'll need to update your bundle to a different version of rake (12.0.0) that hasn't been removed in order to install.

Since rake 12 just came out I constrained the version back to 11.3.0. I am unsure if this was the right thing to do.

I also removed the Gemfile.lock and the vendor/bundle directory and tried many more times with:

bundle install --binstubs --path vendor/bundle
docker-compose build
docker-compose up    

The next error was:

hellorubyvscode_1  | Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.1, file filtering is supported) listens on 0.0.0.0:1234
hellorubyvscode_1  | Looks like your app's ./bin/rails is a stub that was generated by Bundler.
hellorubyvscode_1  | 
hellorubyvscode_1  | In Rails 5, your app's bin/ directory contains executables that are versioned
hellorubyvscode_1  | like any other source code, rather than stubs that are generated on demand.
hellorubyvscode_1  | 
hellorubyvscode_1  | Here's how to upgrade:
hellorubyvscode_1  | 
hellorubyvscode_1  |   bundle config --delete bin    # Turn off Bundler's stub generator
hellorubyvscode_1  |   rails app:update:bin          # Use the new Rails 5 executables
hellorubyvscode_1  |   git add bin                   # Add bin/ to source control
hellorubyvscode_1  | 
hellorubyvscode_1  | You may need to remove bin/ from your .gitignore as well.
hellorubyvscode_1  | 
hellorubyvscode_1  | When you install a gem whose executable you want to use in your app,
hellorubyvscode_1  | generate it and add it to source control:
hellorubyvscode_1  | 
hellorubyvscode_1  |   bundle binstubs some-gem-name
hellorubyvscode_1  |   git add bin/new-executable

So had to run:

rvm use ruby-2.3.3
rvm gemset create rails
rvm gemset use rails
gem install bundler
gem install rails
rm bin/rails
bundle exec rake rails:update:bin

This was confusing because the error above said to run rails app:update:bin

The output was:

bundle exec rake rails:update:bin
DEPRECATION WARNING: Running update:bin with the rails: namespace is deprecated in favor of app: namespace. Run bin/rails app:update:bin instead. (called from load at /Users/ablythe/hbm/ensemble/vendor/bundle/ruby/2.3.0/bin/rake:22)
    exist  bin
identical  bin/bundle
   create  bin/rails
 conflict  bin/rake
Overwrite /Users/ablythe/hbm/ensemble/bin/rake? (enter "h" for help) [Ynaqdh] Y
    force  bin/rake
identical  bin/setup
identical  bin/update

This may need to move into the docker container also… we’ll see.

At this point I was able to get it to work in the debugger which looks like this:

➜  ensemble docker-compose up   
Recreating ensemble_hellorubyvscode_1
Attaching to ensemble_hellorubyvscode_1
hellorubyvscode_1  | Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.1, file filtering is supported) listens on 0.0.0.0:1234
hellorubyvscode_1  | => Booting Puma
hellorubyvscode_1  | => Rails 5.0.0.1 application starting in development on http://0.0.0.0:3000
hellorubyvscode_1  | => Run `rails server -h` for more startup options
hellorubyvscode_1  | Puma starting in single mode...
hellorubyvscode_1  | * Version 3.6.2 (ruby 2.2.6-p396), codename: Sleepy Sunday Serenity
hellorubyvscode_1  | * Min threads: 5, max threads: 5
hellorubyvscode_1  | * Environment: development
hellorubyvscode_1  | * Listening on tcp://0.0.0.0:3000

Now that it is working going to back out the constraint on Rake version.

Removed the rake version constraint from the Gemfile. Delete the Gemfile.lock Delete the vendor/bundle directory

bundle install --binstubs --path vendor/bundle
bundle exec rake rails:update:bin
docker-compose build
docker-compose up  

This was mostly good, however I ran into:

docker-compose up          
Starting ensemble_hellorubyvscode_1
Attaching to ensemble_hellorubyvscode_1
hellorubyvscode_1  | Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.1, file filtering is supported) listens on 0.0.0.0:1234
hellorubyvscode_1  | => Booting Puma
hellorubyvscode_1  | => Rails 5.0.0.1 application starting in development on http://0.0.0.0:3000
hellorubyvscode_1  | => Run `rails server -h` for more startup options
hellorubyvscode_1  | Exiting
hellorubyvscode_1  | A server is already running. Check /app/tmp/pids/server.pid.

I had to remove the file tmp/pids/server.pid in my local copy of the code. When clicking disconnect in the debugger this file is not cleaned up.

This likely needs to be cleaned up. After removing this file then it works again:

docker-compose up
Starting ensemble_hellorubyvscode_1
Attaching to ensemble_hellorubyvscode_1
hellorubyvscode_1  | Fast Debugger (ruby-debug-ide 0.6.0, debase 0.2.1, file filtering is supported) listens on 0.0.0.0:1234
hellorubyvscode_1  | => Booting Puma
hellorubyvscode_1  | => Rails 5.0.0.1 application starting in development on http://0.0.0.0:3000
hellorubyvscode_1  | => Run `rails server -h` for more startup options
hellorubyvscode_1  | Puma starting in single mode...
hellorubyvscode_1  | * Version 3.6.2 (ruby 2.2.6-p396), codename: Sleepy Sunday Serenity
hellorubyvscode_1  | * Min threads: 5, max threads: 5
hellorubyvscode_1  | * Environment: development
hellorubyvscode_1  | * Listening on tcp://0.0.0.0:3000
hellorubyvscode_1  | Use Ctrl-C to stop
ensemble_hellorubyvscode_1 exited with code 1

So it works, but there is still some work to do.