Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

More helpful error message if `thread_safe` is not available #8589

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
Contributor

Crunch09 commented Dec 22, 2012

Hi everyone,
I tried to create a new Rails project with edge rails and it responded with a not very helpful Error Message. The reason for that was, that thread_safe was required but was not available.
So i added a more helpful message, and oriented on this message which solves the same problem with thor.

rails/railties/bin/rails new testapp --edge --dev

Before

/home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- thread_safe (LoadError) from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/Code/rails/edge/rails-dev-box/rails/activesupport/lib/active_support/inflector/inflections.rb:1:in `<top (required)>'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/Code/rails/edge/rails-dev-box/rails/activesupport/lib/active_support/inflector/methods.rb:3:in `<top (required)>'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/Code/rails/edge/rails-dev-box/rails/activesupport/lib/active_support/dependencies/autoload.rb:1:in `<top (required)>'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/Code/rails/edge/rails-dev-box/rails/activesupport/lib/active_support.rb:25:in `<top (required)>'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/Code/rails/edge/rails-dev-box/rails/railties/lib/rails/generators.rb:4:in `<top (required)>'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/Code/rails/edge/rails-dev-box/rails/railties/lib/rails/commands/application.rb:22:in `<top (required)>'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/Code/rails/edge/rails-dev-box/rails/railties/lib/rails/cli.rb:15:in `<top (required)>'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/crunch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from rails/railties/bin/rails:7:in `<main>'

After

The `thread_safe` gem is not available.
If you ran this command from a git checkout of Rails, please make sure it is installed,
and run this command as `ruby rails/railties/bin/rails testapp --edge --dev`
Member

steveklabnik commented Dec 22, 2012

So, I like this idea in theory: improving error messages is always good. However, why was thread_safe not available? If we rely on it, then it should be.

Contributor

Crunch09 commented Dec 22, 2012

Don't know, it just wasn't in the list of my installed gems and i only got the error message away after i ran gem install thread_safe, same with thor afterwards.

Member

steveklabnik commented Dec 22, 2012

What's your Gemfile.lock?

On Saturday, December 22, 2012, Florian Thomas wrote:

Don't know, it just wasn't in the list of my installed gems and i only got
the error message away after i ran gem install thread_safe, same with thorafterwards.


Reply to this email directly or view it on GitHubhttps://github.com/rails/rails/pull/8589#issuecomment-11639992.

Contributor

Crunch09 commented Dec 22, 2012

I just started again with a new rvm gemset, run gem update

*** LOCAL GEMS ***

bundler (1.2.3, 1.2.1)
rake (10.0.3, 10.0.0)
rubygems-bundler (1.1.0)
rvm (1.11.3.5)

executed rails/railties/bin/rails new testapp --edge --dev against the current rails master, it failed. Had to install thread_safe, thor, and i18n (hadn't noticed this one in the first place this morning, weird) by hand. Then it run through and here is the Gemfile.lock
https://gist.github.com/4360555

Member

steveklabnik commented Dec 22, 2012

Okay, your lock shows thread_safe 0.1.0. I'm not totally convinced this is a rails bug, exactly. Hm.

Contributor

thedarkone commented Dec 22, 2012

It wasn't available because @Crunch09 hasn't run bundle install when using rails from a freshly cloned git repository.

What actually happens is this: Rails relies on certain gems (sprockets-rails, i18n, multi_json, arel, thread_safe etc.) for its core functionality. These are listed as dependencies in Rails' various *.gemspec files, so whenever Rails is installed via rubygems its dependencies also get auto-installed. They are also included in the root Gemfile, so when you are using Rails without installing it as gem (as is in this case with a cloned git repo) a user can run bundle to have them automatically installed.

Member

steveklabnik commented Dec 22, 2012

Right. So when actually using Rails after it's released, the bundle install happens as part of generation. So this is Not A Bug.

Contributor

Crunch09 commented Dec 22, 2012

oh ok, sorry for this, then. And thanks @thedarkone for Explaining.

Contributor

createdbypete commented Jan 6, 2013

For anyone else that might stumble over this, I found bundle exec rails new ~/myapp --edge to make sure the bundled gems are being used not the global.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment