Meaning, with capistrano I want to install ruby (and rvm), some gems by means of bundler, and perform some tasks using them. Is this even possible? When I try to install gems with rvm1-capistrano3 gem, it fails with this:
Installing light_resizer (0.2.0)
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
If I make use of capistrano-bundler alongside above mentioned gem, setting bundle_bins to [] (to be able to install bundler), I can't run tasks like deploy:assets:precompile later on.
What I did is use capistrano-bundler after all, but set :bundle_bins, [:rake], as rake is all I needed. Not a perfect solution, probably, but when was it the last time it was perfect... :)
Related
I am installing the ruby gem mysql-dbd on a new system which is running ruby 2.5. The problem is that it gets a syntax error because at 2.4 ruby combined Integer and Fixed num types.
The failed install leaves the unpacked gem package on disk so I was able to examine the entrails and the fix appears to be trivial (as in insert a '#' in a statement to remove the now redundant reference to FixNum).
My question is having fixed the source how do I go about building and installing the gem? Not being familiar with rake.
BTW the gem has long been "unsupported".
I can't get the gem source repository to load, but you've got at least two options:
Locally, you might be able to build it. Try running rake build from the root folder of the gem, and look in the pkg folder for the built gem. You should be able to then gem install pkg/<gem name>.gem in that folder
If you need to share it with others, push the code up on github. Make your change, and if you're using bundler in the codebase that's using the gem, update your Gemfile to point to your source.
You could try something like this:
# install_dbd_mysql.rb
Fixnum = Integer
require 'rubygems/commands/install_command'
install = Gem::Commands::InstallCommand.new
install.handle_options ['dbd-mysql']
install.execute
Run:
$ ruby install_dbd_mysql.rb
I've searched around the Internet, what is the syntax for installing a gem in a rakefile? the only way I've been able to is to skirt around the issue and use a exec() function e.g.
cmd = "gem install geoip"
exec(cmd)
There has to be a better way for this.
gems:install
Does not seem to work for me
Bundler is used to download gems. Rake is just used to run tasks with the Ruby code itself
You would create a Gemfile, give it a source like this
source 'https://rubygems.org'
and add the gems you want like this
gem 'rails'
then run bundle in the directiory with the Gemfile and it gets all of the gems you need.
Hi guys sometimes I work a gem and sometimes to develop this gem I need a Rails application.
Actually when I do this I make my gem in the vendor/plugins/my_gem/ directory and I do all work in this directory.
May be there is other way to do this, more cleaner (plugin like this won't work in rails 4.0).
I normally work have a separate, version-controlled projects for every custom gem that I work on. I normally create gems using Bundler, although there are other options. I specify rake as a development dependency in the my_gem.gemspec. After I'm done writing code and specs in the gem, I normally assign it a new version, then run:
# cd/to/my_gem
bundle exec rake build # build a gem
ruby -S gem install ./pkg/my_gem-0.0.1.gem # install it locally
# cd/to/app_using_gem/
gem unpack my_gem -v 0.0.1 --target ./vendor/gems # vendorize gem
I think this way is cleaner than modifying code in vendor/plugins/my_gem/
I have a ruby script that I want to send to a couple of coworkers. Instead of telling them to install a few required gems, is there a safe way to have ruby install them if not found?
For example, a user doesn't have the yui-compressor gem. Instead of the terminal displaying an error when they run ruby example.rb it would automatically run gem install -r yui-compressor for them. Is there a way to handle this?
You could use a tool like bundler: http://gembundler.com/
I have JRuby and Ruby (MRI) installed. It seems that I need to install gems twice - once for each of these platforms. Is this necessary or am I doing it wrong? After I installed the rails gem for MRI, should I have pointed JRuby to it, or was it necessary for me to also call: "jruby -S gem install rails"
You need to install gems for each different install of ruby that you have.
If you set GEM_HOME you can share your gem installations.
Some gems target specific platforms, e.g. Mongrel (there's a MRI one and a JRuby one). Also, JRuby cannot use gems that have native extensions (i.e. C code) unless they use the FFI (which most do not - yet).
Personally I have separate gem repos for MRI and JRuby. The little bit of extra hassle is worth the peace of mind when trying to track down a problem.
It's pretty easy to see what each repo has installed:
jruby -S gem list --local
vs.
gem list --local
You could even write a ruby script to sync one gem list to the other, but you'd have to be careful about platform specific gems....
I hit this problem when creating my gem, jimmy_jukebox, but made my gem work with both.
First, JRuby doesn't handle fork...exec (and even replies incorrectly to Process.respond_to?(:fork)), so I had to rescue NotImplementedError and use Spoon.spawnp instead.
I then created (in my gem's /bin directory) paired executables -- play_jukebox and jplay_jukebox; and load_jukebox and jload_jukebox -- each with the correct shebang line (/usr/bin/env ruby or /usr/bin/env jruby).
I'd love to know a better way. But I'd rather handle everything within a single gem than maintain and distribute multiple gems.