I have been trying to install rubygems through RPMs (because my target machine doesn't have an internet connection). Now I need to install both json-1.8.1 and json-1.6.8 gems. I have generated RPMs for both the versions though fpm. I installed both of them, but only one of them is visible in gem list.
# rpm -q rubygem-json
rubygem-json-1.8.1-1.x86_64
rubygem-json-1.6.8-1.x86_64
The gem list shows only one version installed.
# gem list
*** LOCAL GEMS ***
json (1.8.1)
Now, when I did yum check, the output is:
# yum check
Loaded plugins: langpacks, presto, refresh-packagekit
rubygem-json-1.8.1-1.x86_64 is a duplicate with rubygem-json-1.6.8-1.x86_64
Error: check all
I am able to install different versions of some of the gems like puma, mime-types. But I am having issues with json.
How can I install both the versions, so that the dependencies can be resolved?
Related
I am trying to bundle on FreeBSD and it cannot find the grpc gem. I installed the grpc 1.30.2 version using a FreeBSD package but it cannot find the system gem.
I'm hoping there is a bundle config setting to find and use the system gem which is already built and intalled.
The error I get is:
An error occurred while installing grpc (1.30.2), and Bundler cannot continue.
Make sure that `gem install grpc -v '1.30.2' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
grpc
* bundle install
Warning: the running version of Bundler (2.0.2) is older than the version that created the lockfile (2.2.11). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
/usr/local/lib/ruby/site_ruby/2.7/rubygems/package.rb:509: warning: Using the last argument as keyword parameters is deprecated
/usr/local/lib/ruby/site_ruby/2.7/rubygems/package.rb:509: warning: Using the last argument as keyword parameters is deprecated
/usr/local/lib/ruby/site_ruby/2.7/rubygems/package.rb:509: warning: Using the last argument as keyword parameters is deprecated
/usr/local/lib/ruby/site_ruby/2.7/rubygems/package.rb:509: warning: Using the last argument as keyword parameters is deprecated
Some gems seem to be missing from your vendor/cache directory.
Could not find grpc-1.30.2 in any of the sources
* Visruleparser
A extras/visruleparser.pl
Export complete.
* precompile assets
Could not find grpc-1.30.2 in any of the sources
Run `bundle install` to install missing gems.
My Gemfile has these lines
source 'https://rubygems.org'
gem 'grpc', '1.30.2'
gem 'grpc-tools', '1.30.2'
The Gemfile.lock has these
grpc (= 1.30.2)
grpc-tools (= 1.30.2)
These FreeBSD packages are installed
>pkg info -x grpc
grpc-1.22.0_4,2
rubygem-grpc-1.30.2
>gem list grpc
*** LOCAL GEMS ***
grpc (1.30.2)
Listing remote gems shows nothing on FreeBSD
>gem list --remote -all gprc
*** LOCAL GEMS ***
But on macOS I get these (among others)
>gem list --remote --all grpc
grpc (1.37.0 ruby universal-darwin x64-mingw32 x86-linux x86-mingw32 x86_64-linux,
1.36.0 ruby universal-darwin x64-mingw32 x86-linux x86-mingw32 x86_64-linux,
...
1.30.2 ruby universal-darwin x64-mingw32 x86-linux x86-mingw32 x86_64-linux,
...
The gem is installed in the directory /usr/local/lib/ruby/gems/2.7/gems/grpc-1.30.2 with a src subdirectory and a ruby subdirectory below that.
>ls /usr/local/lib/ruby/gems/2.7/gems/grpc-1.30.2/src/ruby
bin ext lib pb spec
Environment
FreeBSD 11.4
Ruby 2.7.2p137
RubyGems 3.0.8
Bundler 2.1.4
Looks like this may be my fault. The gem packages purposefully remove the cache dir from the gem. This was originally added here:
https://cgit.freebsd.org/ports/commit/Mk/bsd.ruby.mk?id=8d77480356f58d6d8d1c69884d1ba9cc98ed383a
and lives on here:
https://cgit.freebsd.org/ports/tree/Mk/Uses/gem.mk#n111
${RM} -r ${STAGEDIR}${PREFIX}/${CACHE_DIR} 2> /dev/null || ${TRUE}
This was added because so many gems include large amounts of stuff that is never used in the cache dir, including complete copies of source, intermediate build output, etc. that shouldn't really be packaged.
If you're building your own packages you can try the line from gem.mk that removes the cache dir. Otherwise, we may need to revisit this upstream. Regardless, you should probably open a bug upstream at:
https://bugs.freebsd.org/bugzilla/
But there are tradeoffs and I'm not sure about the use case of bundling gems installed from system packages. (I haven't been using Ruby as much recently.)
Even I have installed ruby-dev and ruby-make but still giving same error ? how to fix the error ?
sudo gem install mechanize
Building native extensions. This could take a while...
ERROR: Error installing mechanize:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.4.0/gems/unf_ext-0.0.7.5/ext/unf_ext
/usr/bin/ruby2.4 -r ./siteconf20180417-8728-15wdd1s.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.4.0/gems/unf_ext-0.0.7.5 for inspection.
Results logged to /var/lib/gems/2.4.0/extensions/x86_64-linux/2.4.0/unf_ext-0.0.7.5/gem_make.out
You don't have the source code for Ruby so when it attempts to compile the gem it fails. It's looking for /usr/lib/ruby/include/ruby.h but that file isn't present on your system.
Generally, it's not a good idea to use the system version of Ruby. (for this reason, and others) You should use a Ruby manager to install Ruby into your user profile, as this will make compiling gems a lot easier.
For example, you can use RVM to install Ruby:
\curl -sSL https://get.rvm.io | bash -s stable
This will install the latest version of rvm, which you can then use to install Ruby 2.4:
rvm install 2.4
You can install nearly any version of Ruby by specifying its version, for example Ruby 2.5:
rvm install 2.5
Afterwards, running ruby will automatically run the version installed by RVM. And since it's installed in your profile, you don't need to use sudo for any operations. (and you should never use sudo when using rvm or Rubies installed by rvm)
In your case, you would then be able to run gem install mechanize successfully because it would be using the Ruby installation in your home directory that includes a copy of the source code and header files.
If for some reason you can't use RVM or don't want to use RVM, then you need to have the Ruby header files installed. The way to install these headers varies by operating system so there's no one answer I can give you. If your OS is a Debian-based version of Linux, for example, you can install the headers with:
sudo apt-get install ruby2.4-dev
More information is available in another answer on stackoverflow.
vagrant plugin install vagrant-parallels
Installing the 'vagrant-parallels' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing little-plugger (1.1.4), and Bundler cannot continue.
Make sure that gem install little-plugger -v '1.1.4' succeeds before bundling.
Warning: this Gemfile contains multiple primary sources. Using source more than once without a block is a security risk,
and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run bundle config disable_multisource true.Warning: this Gemfile contains multiple primary sources. Using source more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run bundle config disable_multisource true.Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/little-plugger-1.1.4.gem)
when I change the --plugin-source
vagrant plugin install vagrant-parallels --plugin-source https://ruby.taobao.org/
The error is the same.
Then I try
gem install little-plugger -v '1.1.4'
Successfully installed little-plugger-1.1.4
Parsing documentation for little-plugger-1.1.4
Done installing documentation for little-plugger after 0 seconds
1 gem installed
Then
vagrant plugin install vagrant-parallels --plugin-source https://ruby.taobao.org/
It still don't work
I try to change all the gemfile source
source "https://ruby.taobao.org
But It still don't work.
I use gem sources -l
$ gem sources -l
get follow:
https://ruby.taobao.org/
I don't know how to fix it.
I have a stupid way
first
gem install little-plugger -v '1.1.4' in /Library/Ruby/Gems/2.0.0
and then copy
sudo cp -r gems/little-plugger-1.1.4/ /opt/vagrant/embedded/gems/gems/
sudo cp -r specifications/little-plugger-1.1.4.gemspec /opt/vagrant/embedded/gems/specifications
sudo cp -r doc/little-plugger-1.1.4 /opt/vagrant/embedded/gems/doc
sudo cp cache/little-plugger-1.1.4.gem /opt/vagrant/embedded/gems/cache
It worked.
But what other convenient way can set the gem install path
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.
We have a ruby application that depends on a gem with native extensions (in this specific case Nokogiri). However, for various reasons we cannot install the build prerequisites (such as build-essential, libxslt-dev, ruby-dev, etc) for that gem onto our production host.
Is there a (standard?) way to repackage the gem with the native extensions pre-built?
It should be possible (it seems to be fairly standard to do this for Windows), but I can't find any documentation on the subject.
Note that we only need to support a single platform, with known versions of all system libraries (Ubuntu 9.04 Server 64 bit, Ruby 1.8.7).
UPDATE:
We're using Bundler, so we want to still have a gem to install at the end of the day, not a debian package.
Finally found a way to do this for gems that use rake-compiler for building their C extensions (which is most of them).
You need to do the following on a machine that is identical to the one you want to deploy to, or it simply won't work:
Install the build prerequisites for building C extensions:
# apt-get install build-essentials ruby-dev # ... etc
# gem install rake-compiler
Unpack the gem you want to rebuild:
$ gem unpack nokogiri
Build your shiny new precompiled gem:
$ rake native gem
You can now install the native gem on a machine without any build tools installed:
$ gem install pkg/nokogiri-1.4.3.1-x86-linux.gem
Successfully installed nokogiri-1.4.3.1-x86-linux
1 gem installed
Build machine
To have the correctly platformed version for all of your gems already cached,
package all gems in vendor/cache on an identical machine:
$ bundle package --all
Prduction machine
Install all gem dependecies already cached that requires to have the correctly
platformed version using the gem cache:
$ bundle install --local --deployment