I am using Ubuntu 12.10 and I am trying to get my project up and running using rbenv and bundler.
I have successfully installed rbenv from the apt repository and installed the required version of ruby using ruby-build.
When I run which gem I get the global /usr/bin/gem that I assume came with the apt repository install. However when I run rbenv which gem I get the proper local gem /home/kasuko/.rbenv/versions/1.9.2-p290/bin/gem
However when I run gem install bundler I get an error on permissions with "Permission denied - /var/lib/gems" which leads me to believe that it is using the global gem.
So when I run /home/kasuko/.rbenv/versions/1.9.2-p290/bin/gem install bundler it successfully installs bundler
I do have the rbenv init line in my ~/.zshrc.local (which is sourced in my ~/.zshrc) and I get the updated path "/home/kasuko/.rbenv/shims:/home/kasuko/.bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" so I'm pretty sure it's installed correctly.
So why aren't my rbenv shims being used?
Thanks
Kasuko
If you're not sure which gem is being executed, try gem env which will show you useful information about the version of gem you're running, such as the rubygems version, corresponding ruby executable, gem paths and other good stuff.
Your PATH seems correct. Try running hash -r to clear the shell's cache of executable paths just in case.
Once you've done this, which gem should give you /home/kasuko/.rbenv/shims/gem, which would indicate that it's deferring to rbenv to determine the actual executable to run.
You may then need to run rbenv rehash. This should be run every time you install a new gem with an executable (like bundler, rake, etc). It will update all the shims to point to the correct executables.
Related
I have limited privileges on a shared machine I'm using, so I can't install gems the way I'm used to. For example:
$ gem install request-log-analyzer
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/lib/ruby/gems/1.8 directory.
Is it possible to install a gem locally? (if it matters, I'm trying to install this gem.)
I saw a number of posts on Stack Overflow that talked about using Bundler or gemfiles but I'm not installing this gem for a Ruby on Rails project - I just want to use it in isolation.
I'm running Linux, not sure which flavor though.
You can try:
gem install --user-install gem_name
Add the --local flag to your install:
gem install --local request-log-analyzer
If that causes any problems, try downloading the gem manually and pointing gem directly to it using:
gem install --local path/to/gem/filename.gem
If you want to install it to your user home, as per rubygems:
When you use the --user-install option, RubyGems will install the gems
to a directory inside your home directory, something like
~/.gem/ruby/1.9.1. The commands provided by the gems you installed
will end up in ~/.gem/ruby/1.9.1/bin. For the programs installed there
to be available for you, you need to add ~/.gem/ruby/1.9.1/bin to your
PATH environment variable.
The command for this would just be
gem install --user-install request-log-analyzer
You could just use RVM: Ruby Version Manager. It is a complete version manager, along the lines of node version manager (nvm) and others, in that it allows you to have different versions of ruby and different collections of gems for each project. It does the job of keeping gems isolated from each other as well as from the system ruby, but at the expense of learning a complete version manager.
When run without root, it installs locally in ~/.rvm and doesn't affect other users.
I am facing a issue with RVM and installed ruby debian/ubuntu package.
As long as I have only installed RVM every works fine. I can use the ruby version which is provided/installed by RVM. Also if I install a gems package compass everything works fine. The RVM is installed as recommended by RVM as single user.
As soon as I install a ruby ubuntu package (which is mandatory for some other ubuntu packages and I have not a option to remove it) my RVM configuration is broken. I cannot execute anymore the compass (command not found) also trying to install it once again with
gem install compass
I am getting
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems
Also
which ruby
which gem
Points to /usr/bin and not to my home?!?
Even if I have set
PATH=/home/rocky/.nvm/v0.10.38/bin:/home/rocky/.rvm/bin:...
I have no clue where to take a look since I am very new to ruby and to RVM. Hope someone can help me?
I am getting Permission denied - /var/lib/gems
/var/lib/gems is owned by root therefore you need to do:
sudo gem install compass
which ruby Points to /usr/bin and not to my home?!? Even if I have
set
This is probably because rvm is not running. Try this:
source ~/.rvm/scripts/rvm
which ruby
Note: Once rvm is loaded correctly, which ruby will point to different location and first question may no longer persist (and so do using sudo).
I'm using ruby, and I was given a zip file with some ruby programs and it says: inside the folder, run bundle install to install the packages required.
When I run the command in my terminal, it says bundle command not found.
Can someone please give me a detailed description of how I can fix this?
gem install bundler
is how to do it.
You may want to use a tool such as rbenv to manage gems.
Just reiterating that for those (at least on OSX) for whom
gem install bundler
Gives a permissions error, an option that seems to have worked for many people is to use rbenv, which kind of adds a shim between your ruby commands (like gem install) and your environment (if my understanding is correct).
Definitely check out this answer.
The process is laid out fairly well under the above link. I chose to install via homebrew:
brew update
brew install rbenv
Then you have to add an argument command to your profile, which if you're using the common ~/.bash_profile, can be done with:
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
Which it looks like is adding a command to initialize rbenv via your shell.
Don't for get to start a new shell, possibly by opening a new terminal or using the source ~/.bash_profile command.
Make sure your $PATH has this .rbenv/shims BEFORE any other directory where your shell might be looking for Ruby (OSX comes with it's own version that we don't want to fiddle with): echo $PATH.
which ruby
/Users/mikekilmer/.rbenv/shims/ruby
#GOOD!
Now install a version of Ruby:
rbenv install 2.2.3
(See all possible versions with rbenv install -l).
Now we can use rbenv global 2.2.3 to switch to a use the newer version of Ruby globally. (Hmm. I thought we didn't want to mess with the system version.) You could also try it with rbenv local 2.2.3 or rbenv shell 2.2.3.
Finally run:
rbenv rehash
Now ruby -v should return 2.2.3 and gem install bundler should work.
Did here.
Just run gem install bundler in your terminal.
There is a link to bundler you can take a look:bundler
Some ruby version managers like chruby and rbenv store gems separately for each version, so when you install a different version of ruby, you'll need to gem install bundler.
Tried every solution here but didn't work out. Eventually I got this to work in two different methods:
Set alias bundle=/path/to/bundle in .bashrc if you don't care the nastiness.
Recreate a fresh dev env via rbenv and do bundle install rails will fix it (fixed my issue).
Terminal -
sudo su
then your password:
change directory :
cd command .
if you do not have permissions to write to drive.
chmod 755 foldername.
And you can also mkdir command in terminal
mkdir /Library/Ruby/Gems/2.3.0.1
copy and paste: gem install bundler paste to the terminal.
Fetching: bundler-1.16.2.gem (100%)
bundler's executable "bundle" conflicts with /usr/local/bin/bundle
Overwrite the executable? [yN] y
bundler's executable "bundler" conflicts with /usr/local/bin/bundler
Overwrite the executable? [yN] y
Successfully installed bundler-1.16.2
Parsing documentation for bundler-1.16.2
Installing ri documentation for bundler-1.16.2
Done installing documentation for bundler after 7 seconds
1 gem installed
works for OS X High Sierra.
I'm working in kali-linux (a linux distro witch is the continuation of Back-Track, based in Ubuntu, just that now is based on Debian wheezy) for some penetration testing. Everything was working just fine, until I decided to update my systems tools. Now whenever I try to run a tool based on ruby, it trows me:
Could not find gem 'ruby-progressbar (>= 1.1.0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
I proceed to run bundle install but then it comes with Bundler::GemfileNotFound error.
Kali use by default ruby, for using gems. The software don't 'require' any other package but ruby seems not-fully-configured/installed for the problem at hand.
$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [i486-linux]
$ rvm
bash: rvm: command not found
$ rbenv
bash: rbenv: command not found
I faced the same problem when I was trying to bundle install without realizing that I was not in the project directory. Make sure you're in the current project directory.
to avoid this error you should be at the root of your application and create GemFile and specify all gems needed in there, and run bundle install
The problem was that for some weird motive Ruby didn't detected that bundler was installed, although the package manager says so.
$ apt-cache policy bundler
bundler:
Installed: 1.3.5-2
Candidate: 1.3.5-2
$ bundle --version
Bundler::GemfileNotFound
I simply run gem install bundler then bundler install as root in the tool root path and everything works as charm.
Do you use rvm or rbenv? If so, make sure you are using a particular ruby version.
For rvm, rvm list and look for an indication next to your ruby version. If the correct one is not listed, run rvm install x.y.z. If the correct one is not selected, run rvm use x.y.z
If you want to segregate your gems for a given project, create a gemset. Otherwise, you should be good to go.
Run gem install bundler. You should not have to do this as sudo. This will install bundler in either the Default rvm gemset, or the selected gemset.
Bundler should now be available and can be run using bundle. This is the same as bundle install.
Try this:
sudo ln -s /var/lib/gems/1.8/bin/bundle /bin/bundle
sudo ln -s /var/lib/gems/1.8/bin/bundler /bin/bundler
Worked for me in debian.
I'm developing a gem which should install an executable.
At the moment I have a file at bin/myexec which does the work. I've got the line gem.executables = 'myexec' in my gemspec, and when I build and install the gem I can do bundle exec myexec anywhere and run my code - sweet.
I'm using rbenv, so I expect some slight shenanigans with binaries, but when I install this gem I need to always bundle exec myexec and I can't just myexec. I've poured over other gems (like guard) to see if there's some quirk of the .gemspec which implies that a rbenv binstub should be created, but I can't see anything.
What am I doing wrong?
Thanks!
If you are using your gem in another project and you installed it using bundler you have to stick with bundle exec myexec. To use your gem system wide you should install it using the gem command and rbenv rehash your environment.
I hope this helps, otherwise it would be nice if you provided some more information how you are using bundler etc.