I am trying to install the ibm_db gem so that I can access DB2 from Ruby. When I try:
sudo gem install ibm_db
I get the following request for clarification:
Select which gem to install for your platform (i486-linux)
1. ibm_db 0.10.0 (ruby)
2. ibm_db 0.10.0 (mswin32)
3. ibm_db 0.9.5 (mswin32)
4. ibm_db 0.9.5 (ruby)
5. Skip this gem
6. Cancel installation
I am always going to be installing the linux version (which I assume is the "ruby" version), so is there a way to pick which one I will install straight from the gem install command?
The reason this is a problem is that I need to automate this install via a bash script, so I would like to select that I want the "ruby" version ahead of time.
You can use a 'here document'. That is:
sudo gem install ibm_db <<heredoc
1
heredoc
What's between the \<\<\SOMETHING and SOMETHING gets inputted as entry to the previous command (somewhat like ruby's own heredocuments). The 1 there alone, of course, is the selection of the "ibm_db 0.10.0 (ruby)" platform.
Hope it's enough.
Try this:
sudo gem install --platform ruby ibm_db
Note that you can get help on the install command using:
gem help install
UPDATE: Looks like this option only works for RubyGems 0.9.5 or above.
Try this, I think it only works on Bash though
sudo gem install ibm_db < <(echo 1)
#John Topley
I already tried gem help install, and --platform is not an option, both in help and in practice:
$ sudo gem install ibm_db --platform ruby
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --platform
UPDATE: The Ubuntu repos have 0.9.4 version of rubygems, which doesn't have the --platform option. It appears it may be a new feature in 0.9.5, but there is still no online documentation for it, and regardless, it won't work on Ubuntu which is the platform I need it to work on.
Versions of Rubygems from 1.0 and up automatically detect the platform you are running and thus do not ask that question. Are you able to update your gems to the latest?
$ sudo gem update --system
Be warned if you are on Windows once you have updated; you might run into this issue.
Another option is to download the .gem file and install it manually as such:
sudo gem install path/to/ibm_db-0.10.0.gem
This particular gem was at rubyforge.
Related
When trying to bundle install on a Gemfile that contained only the GitHub Pages gem and nothing else, on Ubuntu 18.04, I got error messages telling me to try installing eventmachine using gem install. That always succeeds, but bundle install still fails. How can I get bundler to see that the gem is installed?
I fixed this after many hours of struggle, by noticing that on the GitHub Pages repo there's a note that says
Important: Make sure you have Bundler > v1.14 by running gem update bundler in your terminal before following the next steps.
I have no idea why this mattered but I removed my ruby packages from Ubuntu and reinstalled them, then installed bundler with rubygems, which gave me a newer version:
sudo apt-get remove ruby
sudo apt-get install ruby ruby-dev
sudo gem install bundler
bundler --version
If anyone knows why I needed that version of bundler, or how I should have diagnosed this faster, I'd be interested to hear it. I'm not new to programming but I'm new to Ruby.
From my understanding it might be the gem you are trying to install requires a specific feature provided by bundler. If you check the change log of bundler there is some changes related to install github based gems on how to correctly read the user git settings. So I think that might be where the problem is from.
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 need to install json because I get this error:
Could not find json-1.4.6 in any of the sources
I ran gem install json and bundle install but I was only able to install json-1.5.1 when I need json-1.4.6
I have gem 'json', '1.4.6' in my gemfile, so I'm not sure what's going on...
UPDATE
I get this error:
Installing json (1.4.6) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1216:in `chmod': Operation not permitted - /Library/Ruby/Gems/1.8/gems/json-1.4.6/CHANGES (Errno::EPERM)
After checking logs by running $ heroku logs
I found "An error occurred while installing json (1.4.6), and Bundler cannot continue.
Make sure that gem install json -v '1.4.6' succeeds before bundling."
I then removed 2 json entries from the Gemfile.lock and had no further issues.
Why did you run gem install json at all? Bundler takes care of that for you and will ensure that the correct version of each gem is installed (since sometimes dependencies require an older version). Run
gem uninstall json
bundle install
Also ensure you have source 'https://rubygems.org' at the top of your Gemfile.
As for the permissions info, you may have to run gem and bundle commands with sudo.
By the way, I highly recommend taking a look at and using RVM, particularly the gemsets feature. It will make your life infinitely better when developing Ruby apps. If you decide to do so, I'd also suggest trashing all the gems you've install using the system Ruby by running sudo rm -rf /Library/Ruby/Gems/1.8/. It's also important that when using RVM you don't have to use sudo when running gem (or bundle), which is not only safer but less typing too.
Please update your rubygems by executing the following command..
gem update --system
may be it will solve the problem. After updating your gem. Then run the following command to install json
gem install json
Now you can get json gem installed in your system.
Try:
$ sudo apt-get install ruby1.8-dev
If you're using rbenv, try rbenv rehash
I had this problem when trying to build a website with Jekyll.
Turned out I hadn't followed all the instructions at https://jekyllrb.com/docs/installation/ubuntu/
I don't know if it was the missing packages or commands into ~/.bashrc but it fixed the problem in two instances of Ubuntu in WSL
Remove the json entries from the Gemfile.lock file and try to re run bundle install..
I recently started learning Ruby and Ruby on Rails, and have watched a plethora of getting started materials. I have been finding lately that I keep getting errors where gems won't install or they will be installed but they can't be used for some reason, and I have decided that I want to remove everything down to once again just having Ruby installed and start over with the installation. One training video had me install most of my gems with RVM, so I don't know if that changes anything.
So in short my question is "How to I get rid of RVM, Rubygems, and all installed Gems so that I can start over with just Ruby?"
Edit: I am on Mac OS 10.6
gem uninstall -aIx
Uninstalls all gems without prompt.
Options
-a, --[no-]all Uninstall all matching versions
-I, --[no-]ignore-dependencies Ignore dependency requirements while
uninstalling
-x, --[no-]executables Uninstall applicable executables without
confirmation
From the RVM support site:
RVM installs everything into ~/.rvm.
To remove RVM from your system run 'rm
-rf ~/.rvm'. You may have one additional config file in ~/.rvmrc and
of course the RVM hook in your
bash/zsh startup files.
So, just go to the command line and type rm -rf ~/.rvm
All the installed gems are in the ~/.rvm folders, so doing the above will remove the gems and installed rubies in one go.
Gems you added pre-RVM with the default ruby install can be removed by typing this at the command prompt:
for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done
For Windows and Unix copy/paste in command prompt (Ruby 1.9.x).
ruby -e "`gem list`.split(/$/).each { |line| puts `gem uninstall -Iax #{line.split(' ')[0]}` unless line.strip.empty? }"
using RVM, you could just type...
rvm gemset empty GEMSET
where GEMSET is the gemset which you would like to empty. then...
install bundle
yum install bundler and finally
bundle install
rvm implode (see cli docs) seems to work - and it even tells you where to look at for leftovers
This is work for me on Ubuntu 16.04. For me, when I was executing
command rails -v it throw errors because of NameError. I have
installed 3 version of rails (4.2.0, 4.2.6, 5.0.0.1). I was trying
to uninstall unnecessary gem using command gem uninstall rails -v
version number but I won't able to, but I find a way to solve
this problem. In order to uninstall all gems, you have to loop
through all entries in gem list with bash scripting. This method is
very inconvenient. Thanks to Rubygems 2.1.0, you now could do it
with one command.
STEP - 1
Firstly, please make sure you upgrade your Rubygems to 2.1.0 or
newer. For this run this command (Incase you are working on an older
version. You can check your gem version using this command any one
of them gem -v or gem --version)
gem update --system
gem --version
STEP - 2
Run this command in you terminal
gem uninstall --all
Step - 3
Install gem bundles (it is not necessary I think just for
precautions)
gem install bundle
Step - 4
Install the rails on your system using this command
gem install rails -v specific version you want to install you can check the rails version on the official site rails all versions
example :- I have installed rails 4.2.6
version, you install as per requirement.
gem install rails -v 4.2.6
Step - 5
Finally check the version of installed rails framework application
by Using basic command rails -v. It will echoed the current
version of rails frameworks. Enjoy :)
References
http://ruby-journal.com/how-to-uninstall-all-ruby-gems/
http://guides.rubyonrails.org/v4.1/getting_started.html
Step 1:
I first kept running into an error that said:
You don't have write permissions for the /usr/bin directory
To get permission, I became a root user with (this is potentially dangerous for reasons beyond my current understanding):
sudo -s
Credit
Step 2:
Then, I kept running into an error that said:
[gem] cannot be uninstalled because it is a default gem
This allowed me to uninstall everything:
for i in `gem list --no-versions`; do gem uninstall -aIx $i; done
Credit
FWIW, there are some weird cases where gems are installed but not really installed:
This should do the trick reasonably reliably.
gem uninstall -Iax `gem list | grep default | awk '{print $1}'`
https://github.com/Shopify/shopify_api
I've never manually installed something like this before, I have only used gem install xxxx in the past.
I am using RVM.
Update
OK, gem install does work, but how would I install it manually?
It's a gem so you could download it and decompress it, cd into its directory, then run rake. But why? gem install will be less work and will do as well.
gem install path/to/gem/file.gem
It's a gem, it's available from Rubygems, so
gem install shopify_api
See https://rubygems.org/gems/shopify_api