I use capistrano to deploy rails app. I have set up rbenv and using capistrano-rbenv in my deploy.rbfile
Error message when deploying:
Could not find rake-10.1.0 in any of the sources
Run `bundle install` to install missing gems.
On server when I run bundle install I get Could not locate Gemfile
$ gem env returns
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/deployer/.gem/ruby/1.9.1
- /usr/share/rubygems-integration/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
You should confirm that rake 10.1 is on the server through ssh login. It is a dependency to your process.
Rake is a gem like any other, so on the server run
gem install rake -v=10.1.0
if gem which returns nothing, then you need to first install rubygems, e.g.
apt-get install rubygems
Ensure that apt-get properly configures your PATH. You may need to re-source your .bash_profile (or whichever for your shell — or login again to get a new shell
I will update this answer if more details emerge.
I ended up removing the capistrano-rbenvgem and it finally worked out.
If you are requiring capistrano/bundler in your Capfile, be sure to specify the gemfile location in your deploy.rb:
# setup bundler
set :bundle_gemfile, -> { release_path.join('Gemfile') }
See: https://github.com/capistrano/bundler
Related
it's been a while since I setup a brand new Rails environment.
I am trying to get gems to install under ~/.gems as opposed to /usr to avoid sudo-ing constantly.
Here is my gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/myname/.gems
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /home/myname/.gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/myname/.gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri"
- "gemhome" => "/home/myname/.gems"
- "gempath" => ["/home/myname/.gems"]
- REMOTE SOURCES:
- https://rubygems.org/
$ which bundle
/home/myname/.gems/bin/bundle
now I did rails new SomeApp and when I run
bundle install
I get:
Errno::EACCES: Permission denied - /usr/local/lib/ruby/gems/2.0.0/build_info/jquery-rails-3.0.4.info
An error occurred while installing jquery-rails (3.0.4), and Bundler cannot continue
Which tells me that it's still trying to install the gem NOT where I want it. Any thoughts what to check? (I do have a ~/.gemrc file, the contents are the last 3 lines of the GEM CONFIGURATION section above).
Many thanks for all tips -- this was supposed to be a quick and easy step :)
highly recommend rbenv and rbenv-gemset, installing here with homebrew:
brew install rbenv rbenv-gemset
cd into/project/
echo specialgemsetname > .rbenv-gemsets
now start a new terminal (to ensure environment is correct) and setup your project.
I'm getting this error:
Could not find i18n-0.6.1 in any of the sources
Run bundle install to install missing gems.
When i try to run bundle install, i get this:
-bash: bundle: command not found
I have googled and tried to solve this for a while now with no hope. Please help.
Don't mess with your PATH.
Just use rbenv and ruby-build to manage and install your ruby version(s).
And then install the bundler gem and rehash.
Install rbenv (if you haven't already) as follows:
$ brew update
$ brew install rbenv ruby-build
Initialize rbenv as follows:
$ rbenv init
Install ruby-build to compile and install different versions of Ruby on UNIX-like systems:
brew install ruby-build
Install a specific ruby version, e.g., 1.9.3-p551:
$ RUBY_VERSION=1.9.3-p551
$ ruby-build $RUBY_VERSION $HOME/.rbenv/versions/$RUBY_VERSION
Verify it worked:
$ ruby --version
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin14.0.0]
Set that version to be the global/default Ruby version:
$ rbenv global 1.9.3-p551
Install bundler:
$ gem install bundler
Fetching: bundler-1.7.11.gem (100%)
Successfully installed bundler-1.7.11
1 gem installed
Update rbenv:
$ rbenv rehash
Now, bundler will be available in the version of Ruby (1.9.3-p551) that you just installed.
Verify RubyGems Environment:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23.2
- RUBY VERSION: 1.9.3 (2014-11-13 patchlevel 551) [x86_64-darwin14.0.0]
- INSTALLATION DIRECTORY: /Users/lex/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/lex/.rbenv/versions/1.9.3-p551/bin/ruby
- EXECUTABLE DIRECTORY: /Users/lex/.rbenv/versions/1.9.3-p551/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/lex/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1
- /Users/lex/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- "install" => "--no-ri --no-rdoc"
- "update" => "--no-ri --no-rdoc"
- :sources => ["http://rubygems.org", "http://gems.github.com", "http://gems.rubyforge.org", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://rubygems.org
- http://gems.github.com
- http://gems.rubyforge.org
- http://gemcutter.org
try to run
gem env
and then you will get something like this:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-darwin12.5.0]
- INSTALLATION DIRECTORY: /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/Cellar/ruby193/1.9.3-p448/bin/ruby
**- EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby193/1.9.3-p448/bin**
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1
- /Users/madhava/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Just add the executable directory to your PATH variable like this:
echo PATH=/usr/local/Cellar/ruby193/1.9.3-p448/bin:$PATH >> ~/.bash_profile
Reload your terminal to apply the changes and you will be set!
Seems with Sierra, you need to use this to get bundler installed:
sudo gem install bundler -n /usr/local/bin
Reference here refers to how El Cap introduced "SIP (System Integrity Protection)."
I am on Mac OS X Maverics (10.9.2)
Currently my ~/.profile file reads as follows:
# MacPorts Installer addition on 2014-02-23_at_17:28:39: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
source /usr/local/bin/virtualenvwrapper.sh
. /sw/bin/init.sh
And my PATH variable ($PATH) is set to
/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
This is what worked for me.
First I installed bundler using:
gem install bundler
However I got error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Hence I ran sudo gem install bundler and that installed bundler successfully
After that when I ran gem env I got the Executable Directory set to /usr/bin which is already part of my PATH variable. Hence I didn't make any changes to ~/.profile file.
and now I am successfully able to run bundle install.
If the path listed in Executable Directory is not included in your $PATH variable or ~/.profile file, you will have to include it.
Note that if you're using rbenv, you should probably just rbenv rehash and not mess with your PATH
I'm trying to create a database, but I keep getting the following error:
$jruby -S bundle exec rake db:create
[31mCould not find json-1.7.6 in any of the sources
[33mRun 'bundle install' to install missing gem.
I have run bundle install (including jruby -S bundle install). This post is leading me to believe that maybe there's a problem with my environment. But, after looking at my Gem path and Gem environment, I don't think that's the case.
Here is my Gem path:
["c:/jruby-1.7.3/lib/ruby/gems/shared", "c:/Users/Jesse Flores/.gem/jruby/1.9"]
And my Gem Environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2013-02-21 patchlevel 385) [java]
- INSTALLATION DIRECTORY: c:/jruby-1.7.3/lib/ruby/gems/shared
- RUBY EXECUTABLE: c:/jruby-1.7.3/bin/jruby.exe
- EXECUTABLE DIRECTORY: c:/jruby-1.7.3/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-java-1.7
- GEM PATHS:
- c:/jruby-1.7.3/lib/ruby/gems/shared
- c:/Users/Jesse Flores/.gem/jruby/1.9
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-rdoc --no-ri --env-shebang"
- "update" => "--no-rdoc --no-ri --env-shebang"
- REMOTE SOURCES:
- http://rubygems.org/
Also, I can see json-1.7.6 and json-1.7.6-java in my Gemfile.lock file.
Any ideas as to what's going on here?
Thanks!
Oh, I'm using Windows 8.
As occasionally happens, found the right post that helped me solve the problem just a few minutes after posting the question.
Kaleth's answer on this post: Missing gem when running rake got me pointed in the right direction. With jruby, it's actually something like this:
jruby -S bundle install --path=vendor/bundle
After that, rake -T worked properly.
Whether I use gem install or bundle install for my gems, they don't work. Sometimes sudo gem install gets gems to work. I ran the gem list -d and which gem commands, and it seems that my system is configured such that all the gems get installed into " /Library/Ruby/Gems/1.8" but my environment expects them in "/usr/bin/gem". How could I properly correct this? I was under the impression that 'bundle' should be able to install a local, application specific copy of a gem?
Although many Rubyists will recommend you RVM or RBENV, I do not use it. It's VERY slow and it pollutes your environment.
If you use Bundler, you dont need RVM at all - rubygem itself supports multiple versions of single gems. So you can just start using gems (e.g. gem install etc) and it will install into your $HOME/.gem directory by default. You can check the installation path using:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/lzap/.gem/ruby/1.9.3
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /home/lzap/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/lzap/.gem/ruby/1.9.3
- /usr/share/gems
- /usr/local/share/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- http://rubygems.org/
You can even change this with GEM_HOME environment variable. Happy gemming!
I would suggest using RVM (Ruby Version Manager) to control which version of Ruby you are installing your gems into. It will also help keep all the bundle and gem data in a folder in your home directory.
So this happens to me regularly, where i have gems that are installed but for some reason my rails app is not finding it...here is my example
my config/environment.rb
config.gem "whenever"
my install
sudo gem install whenever
Password:
Successfully installed whenever-0.6.2
1 gem installed
gem list | grep when
whenever (0.6.2)
script/server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
Missing these required gems:
whenever
You're running:
ruby 1.8.7.174 at /usr/local/bin/ruby
rubygems 1.3.7 at /Users/matt/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.4.0]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.8
- /Users/matt/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
- http://gemcutter.org
$ which gem
/usr/local/bin/gem
$ which ruby
/usr/local/bin/ruby
Does anybody see the issue because i clearly cant even start my server and i know the gem is installed. I am on a macbook pro with Snow leopard by the way...
Please check you ruby and gem installation :
May be use these commands
which ruby
which gem
and make sure they have the correct path.
Most times people have these problems is that "gem" command installs gems into a different ruby installation instead of the one used by your rails app.
I had two different 1.9.x ruby versions, and I had installed rvm.
All the gems installed through rvm were not showing up.
Basically my "which gem" was showing /usr/bin/gem while it was supposed to be "/home/gh/.rvm/rubies/ruby-1.9.x/bin/gem"
If such is the case, in your gnome-terminal, under Edit > Profile Preferences > Title and Command, check the option "Run command as a login shell"
This integrates rvm with gnome-terminal :) Hope this helps someone who faced the same issue as I did.
Reference: https://rvm.io/integration/gnome-terminal