Since I am new to rails and have learned the very basics from books I now figured that I can learn quite a bit more from reading other peoples code and trying to make sense of it so I have signed up at github and set up everything there. Now I read that one good open source project to learn from is radiant so I went to https://github.com/radiant/radiant and cloned it to a local directory. THen I proceeded as follows:
cd radiant
bundle install, which went fine
rake db:migrate, which first returned:
rake aborted! You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Using bundle exec may sol
So I typed in bundle exec rake db:migrate and recieved the following:
NOTE: Gem.source_index is deprecated, use specification. It will be removed on or after 2011-11-01. Gem.source_index called from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.14/lib/rails/gem_dependency Rake aborted! No such file to load -- radius
So here I am wondering how to fix this problem? I also noticed that a Gemfile and a Gemfile.lock already existed in the radiant folder when it was cloned, which perhaps could be part of the problem?
Also I wonder if it is crutial that I run the same version of rails as the project is written in?
Now it should be said that I currently have rails 3.0.5 installed and run on windows
I hope someone can help me here, it has been quite frustrating since I have not been able to run any cloned github repos (radiant here just being one example).
You should edit your Gemfile and make it require newer rake.
Also you can run rake db:migrate --trace to get additional error information.
The deprecation warning is still just a warning, and it shouldn't be causing you any issues. The part of that error that is relevant is the No such file to load -- radius. You probably need to follow the instructions for installing Radiant, which include running a gem install radiant before dropping this project code somewhere.
Bundler manages installing and using the gems in your Gemfile, and if a Gemfile.lock is present it'll use those exact versions. This means you can't run Radiant with Rails 3.0.5 since the Gemfile specifies 2.3.14. Bundler will install Rails 2.3.14 and its dependencies automatically, though, so you don't need to worry about it.
By the way, this project looks like it has been very mismanaged. It's not common for a Rails project/gem to force you to actually clone it to use it. If you want to check out a Rails 3 project to learn from, I have a slim Rails 3 app that was intended to be an API up publicly on Github with some really clean code: http://github.com/coreyward/instavibe
Related
When I run a rails console using
rails console
everything is fine.
When I run a rails console using
bundle exec rails console
I get the following warning
Bundler is using a binstub that was created for a different gem.
This is deprecated, in future versions you may need to `bundle binstub my_gem` to work around a system/bundle conflict.
my_gem happens to be a gem that I've created that is completely unrelated and not used in the current project directory.
I've tried every solution in this question with no luck:
Bundler is using a binstub that was created for a different gem
I would appreciate any guidance on removing this warning or help understanding how binstubs work so that I can figure out what's going on.
Nowadays it's common for projects to have "specialized" versions of tools. E.g. in some projects the "rails" command may be expected to be run using "spring" (to start up faster).
So it's not uncommon to generate files in your project's 'bin' directory, and then use those versions when running commands, so e.g. instead of
bundle exec rails console
or
bundle exec spring rails console
you could simply expect the following to work correctly
bin/rails console
and not care whether the project needs spring or bundler or zeus or whatever.
So if you don't have 'bin/rails' in your project, you should generate one that suits the project, e.g. using
bin/rake rails:update:bin
If you don't already have bin/rake, you might have to use
bundle exec rake rails:update:bin
(so your bin/rake commands will also get a speedup from using spring)
Some people even put ./bin in their paths, so whenever they run rake (or whatever) they are actually running ./bin/rake if it exists.
Troubleshooting
for project specific tasks, use bin/* files, creating them if needed (e.g. using special rake tasks like in Rails or using bundle binstub <gemname>) - usually those have Bundler specific lines that will make Bundler happy.
for non-project gems (like your gem), find out where it is (e.g. which mygem) and check out it's contents - it's probably using e.g. "bundler/setup" which is confusing Bundler (because bundler expects a local Gemfile file). Maybe your gem is using bundler (it shouldn't if it's a "global" kind of tool and not a "project" tool).
Also, if you're using them, check if tools like RVM and .rbenv are correctly adding their stuff to your bin files (they usually need to setup specific paths)
If you still have questions, it's best to post the contents of the bin file causing problems - it's meant to be a plain Ruby file, so if there's something wrong, it's usually because of the file contents (and not anything else).
More info: https://github.com/sstephenson/rbenv/wiki/Understanding-binstubs
It happened in a project of mine. Because I ran bundle install with another ruby version.
Make sure your rvm is the correctly ruby version.
I installed rails 3.2.3 in my pc but for my new project i need to work in rails 3.0.5 so I installed 3.0.5 version of rails and now when i write any rake command i get the following error
rake aborted! ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
currently this rake version is installed in my pc rake (10.1.0)
I know the error says everything but im new in ruby and rails. So i don't understand what to do. I googled it but most of the solutions ask to update rails
I know the error says everything but im new in ruby and rails. So i don't understand what to do. I googled it but most of the solutions ask to update rails
That's unfortunately the best solution. You are using a very old version of Rails that was based on some conventions of the time. Rake has changed and 10.0 is no longer compatible with that Rails version.
You should install a previous rake version. 0.9.0 should be sufficient.
In your Gemfile set
gem 'rake', '0.9.0'
then run $ bundle. Make sure you will prefix every command with
bundle exec
such as
bundle exec rake -T
instead of
rake -T
otherwise the script will fall back again using the most recent version of Rails on your machine.
For your reference, the reason of the error is probably caused by the documentation.rake file that at the very beginning it includes a deprecated rake file, removed in GH-1301.
Keep in mind that, assuming the app will then run, your first goal should be to upgrade your app. In fact, if you try to use it as it is, it's likely you will encounter so many other incompatibilities.
That was fairly simple to debug (assuming you have a reasonable knowledge of Ruby and Rails internals), but others may be harder or even impossible to fix forcing you to nothing else than upgrade.
I'm having this error message come up during Capistrano deployment. It implies to me that something's wrong with Rails being installed or something? Rails is not currently installed on the server side, but it's in my Gemfile (and my Gemfile.lock), so I'm assuming it should be installed during the bundle install command that gets executed before this line.
The actual command that's giving the error is:
bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile
I guess the problem is just that Rails is not being installed during the bundle install. Am I missing something?
Thanks!
UPDATE 1: Rails appears to be installing correctly via the bundle install command. If I check out the directory .../shared/bundle/ruby/1.9.1/gems, I can see action mailer in there.
UPDATE 2: Running the command rake assets:precompile actually fails locally as well, so this doesn't have anything to do with Capistrano it would appear. Now I just have to figure out why the config object doesn't know anything about action mailer?
UPDATE 3: Hot on the trail. It looks like my installed version of actionmailer is 0.6.1 (?!), meanwhile all the rest of my Rails stuff is up at 3.2.9. bundle update refuses to update actionmailer past this version. I'm going to remove all of my gems and start fresh.
UPDATE 4: Deleted my entire gemset using rvm gemset empty. Then tried to run bundle again, and again it tries to get actionmailer 0.6.1. I think something is screwed up with bundler or something...
The problem ended up being that I had removed a dependency upon a specific version of Rails in my Gemfile. I just had gem "rails" in there. That seemed to completely botch the dependency calculations, because it was getting super-old versions of action mailer rather than getting a consistent version from all gems. Guess it's a bad idea to not specify an exact Rails version. Yikes!
#aardvarkk,
Thanks for posting this issue, I was having the same error with my installation of Rails 4.0.0 and the error was preventing me from running my rails server
This is while I'm trying to follow the Hartl Tutorial for RoR.
I added gem "rails", '4.0.0' to my gem file and now I'm able to run my rails server.
Thank you
I'm trying to use config/environment.rb to install a ruby gem dependency (because I don't have sudo access to our server; ergo, can't just call gem install hpricot).
I've tried including sundry arguments (:version, :source, :lib) but I still get rake aborted! no such file to load -- hpricot
Update: It turns out that when I remove the plugin which requires hpricot, then I can execute rake gems:install successfully. But that's not very helpful. It means that if I ever move my app, I run into a problem of being unable to rake its gems (because I will have reinstalled the plugin and added features that depend on it).
How is this supposed to work?
Sys: WinXP, Ruby 1.8.7, Rails 2.3.5
Rails is trying to load the gem before executing the rake task. This is a known issue with rails 2.x. The only solution I know of is to switch to using bundler to manage gems or manage then manually.
Bundler can be used with rails 2 but it requires some modifications to your application and deployment scripts. This is a good place to start: http://gembundler.com/rails23.html
rake gems:install has been deprecated because it never really worked. You can imagine having a gem installer with dependencies to the very gems it's trying to install is a bad idea.
It's advisable to use bundler instead if that's an option.
Bundler allows you to install gems to any destination you want, something specifically intended to side-step the whole "requires sudo" problem you describe. It's often as easy as this:
bundle install --path ~/my_gems/
You can make your Rails 2.3.x application use Bundler by following a few simple steps and from there your life will be a lot easier.
I recently upgraded a rails project I am working on from 2.0.5 to 2.3.2. I noticed that there was a local copy of the 2.0.5 rails files in vendor/rails and I was wondering should I put a local copy the 2.3.2 rails files in there too or just leave them out? What is considered a better practice?
Yes. The copy of Rails that sits in vendor/rails is actually used in preference to the Rails gems installed system-wide—in other words, though you upgraded your Rails install, your app is actually still running on 2.0.5.
The vendor/rails directory exists so you can "freeze" your app to a specific version of Rails, thus making it less vulnerable to changes in the configuration of the machine it's running on. This is so darned useful that there's an automated way to manage the directory. To delete the existing version of Rails sitting in vendor/rails, go to the root of your Rails project directory and do the following:
rake rails:unfreeze
To then install the most current Rails gems on your system into vendor/rails, do:
rake rails:freeze:gems
There are a few other things you can do with vendor/rails. Check out rake -T for a full list of commands.
P.S. If you ever hear someone talk about their Rails install being "vendored", this is what they mean.
In the meanwhile things have changed a little.
rake rails:freeze
and
rake rails:unfreeze
are deprecated. Instead you should use:
bundle install --path vendor/bundle
and
bundle install --system
to switch back.