简体   繁体   中英

Cannot use locally installed gems

I am trying to run a Ruby on Rails website on a shared hosting. When I get to rake db:create (or rake at all) following this tutorial http://guides.rubyonrails.org/v2.3.8/getting_started.html I get

ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.

I tried gem install rdoc -v 2.4.2 (also tried gem install rake --version 0.8.7 as suggested here ERROR: 'rake/rdoctask' is obsolete and no longer supported ), but my problem is that the other versions are installed globally on the system by my hosting provider and for whatever reasons the global versions override the local ones.

I also tried gem install bundler to try to specify versions (as suggested here Use older version of Rake ), but bundle responds with

/usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [actionmailer-2.3.15, actionpack-2.3.15, activerecord-2.3.15, activerecord-mysql2-adapter-0.0.3, activeresource-2.3.15, activesupport-2.3.15, cgi_multipart_eof_fix-2.5.0, daemons-1.1.9, fastthread-1.0.7, gem_plugin-0.2.3, mongrel-1.1.5, mysql2-0.3.11, rack-1.1.5, rails-2.3.15, rake-10.0.3, rubygems-update-1.8.25, sqlite3-1.3.7] (Gem::LoadError)

I don't have RVM installed by my hosting provider, which might have allowed me to do something like this RVM doesn't set correct gem path .

Curiously enough gem which rake gives me

~/ruby/gems/gems/rake-0.8.7/lib/rake.rb

(home directory concealed by me), but ~/ruby/gems/gems/rake-0.8.7/bin/rake --version gives me

rake, version 10.0.3

I get a similar result about rdoc, and ~/ruby/gems/gems/bundler-1.3.5/bin/bundle --version gives me

/home/ko64eto/ruby/gems/gems/bundler-1.3.5/bin/bundle:7:in `require': no such file to load -- bundler (LoadError) from /home/ko64eto/ruby/gems/gems/bundler-1.3.5/bin/bundle:7

What can I do to resolve the rake vs rdoc conflict. Do I need to ask my hosting provider to install RVM or can I do something else? If I contact them, is there any other option I could ask them for (like asking them to install bundler globally, or update rdoc)?

What version of Rails are you using? Can you share your Gemfile?

If you are using Rails 3.2.x then you could try bundle install --deployment. Your hosting provider should probably have bundler installed already. Is bundler installed? Try gem list bundler and tell me what you see.

If bundler IS installed then you want to try bundle exec rake db:setup or bundle exec rake db:create. Then bundler will use the version of rake in your gemfile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM