I tried to modify an existing gem and forked the git repository.
I added some commits and pointed bundler to my GitHub repository.
bundler update does recognise the change and downloads my version of the gem.
Anyway when I try to launch the application which depends on that gem (testkitchen) my changes aren't available. And when I delete the official version of the gem my version is not found/used and the app fails.
The weird thing is that all the official gems are installed to /var/lib/gems and my version goes to ~/.bundler
gem environment also shows up the correct directories
- GEM PATHS:
- /var/lib/gems/2.2.0
- /home/ansible/.bundler/ruby/2.2.0
I'm not using rvm or similar. Am I doing something wrong?
As #matt pointed out I forgot to add bundle exec to my commands.
Related
I want to put a debugger in a file for testing, but can't find where Bundler installs gems pulled from Github on my local machine.
I've looked at this thread http://bundler.io/v1.5/git.html which shows how to setup a local file repo to pull from, but I would rather avoid this as my situation is a one off debugging scenario.
I use rbenv for my ruby and gem management. When I pull in a gem from a git repo, it places the files for the gem here:
/usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/gem-name-SHA/
On my machine bundler installed the gem in:
~/.rvm/gems/ruby-2.3.3/bundler/gems/gem-from-github
gem which [GEM] doesn't work on its own, but bundle exec gem which [GEM] does.
I'm not new to programming, but brand new to Ruby. Everything's working, but I'm still missing a key concept: how do you install a plugin and where/how do you include it in an app?
Example:
I'm trying to use the Facebooker2 plugin: https://github.com/mmangino/facebooker2. In the readme, step 1 is to "Install facebooker2 as a plugin in your rails app." I've run the command git clone https://github.com/mmangino/facebooker2.git to download a read only version of the repository.
Do I then bundle that up using Bundler, or do I need to create a gem file in some way? Do I simply
use gem to install it, or do I need to compile it into a gem?
Any help (terminal commands or otherwise) are extremely helpful.
I looked at the repo and it's set up as a gem. You can simply add
gem 'facebooker2'
to your Gemfile (in the root of your project) and run
bundle install
to download it and add it to your list of installed gems, both in development and in production.
Rails used to include the concept of plugins (added to your /vendor/plugins directory) but that's been dropped in favor of gems.
If you're source is source 'https://rubygems.org' but the gem you need is specific to github and not part of the rubygems.org library, then you can add the git method to your gemfile. You can also select a specific branch version. For example, here I have the gem cancan being pulled from the github repository on the 2.0 branch.
gem "cancan", :git => "git://github.com/ryanb/cancan.git", :branch => "2.0"
I'm trying to install lazy_high_charts gem for my Rails project and am having some issues. The gem installs fine but I'm not seeing the most recent changes to the source in my local copy. In my gemfile I have
gem 'lazy_high_charts'
and it works fine. I also tried
gem 'lazy_high_charts', :git => "https://github.com/michelson/lazy_high_charts.git"
Basically I want to use this change to the gem, but I can't get it installed.
You'll want to use the git option that you are trying to use above for now (I don't think the most recent changes have been packaged into the gem yet), and it looks correct. I usually use the git address, however.
gem "lazy_high_charts", git: 'git://github.com/michelson/lazy_high_charts.git'
Make sure you re-run bundle install and restart your server (kill the running process and run rails s)
I have a Gemfile with a private git repo in the following format:
gem 'magic_beans', :git => "git#git.example.com:magic_beans.git', :branch => 'super_beans'
When I bundle install, the Gemfile.lock locks it to a specific SHA revision.
Can I get bundler to always check and use the latest SHA commit and/or update the Gemfile.lock? Notice that when I push updates to the super_beans branch I am not modifying the gem version.
Ideally, every time I run bundle it would check upstream git repo for a newer SHA revision of the branch.
This isn't how bundler works.
The point is to allow seamless versioning of dependencies.
(particularly so you know exactly what version of the code is deployed at any given time).
If want the latest version, you should just run.
bundle update magic_beans
This is exactly the same functionality as if you just say
gem "rails"
I'd suggest though, if you have a range of specific things you want to update
then add a custom binary (say an executable file named bundle_update)
#!/usr/bin/env bash
bundle install
bundle update magic_beans
Then just do a ./bundle_update when you want to update these things.
You can run bundle update to update all or specific gems to their latest available version, as stated in the docs.
Would that help?
After searching through the documents I finally found the magic way to do this:
bundle update magic_beans --source magic_beans
That is to update the magic_beans gem only, but not to touch other locked gems. The doc about this is: http://bundler.io/man/bundle-update.1.html
delete .gemlock is what worked for me :/
Can not update gems on production server.
I've tried bundle install --deployment and bundle install --without development test
But keep getting:
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
If this is a development machine, remove the Gemfile freeze
by running `bundle install --no-deployment
EDIT
I don't know if this is correct, but needed a quick fix. I ran bundle install --no-deployment then bundle update then ran bundle install --deployment again
The instructions are probably a bit confusing. It's saying that you've modified your Gemfile on your development machine and just pushed those changes rather than running bundle install BEFORE committing the changes.
By running bundle install you will update your Gemfile.lock file. This should be pushed to your server as it's more important than Gemfile. Consider the Gemfile the plans for the Gemfile.lock file.
Always remember to:
Run bundle install if you change your Gemfile, even just to make sure. If it's too slow, pass --local through which forces it to only use local gems to resolve its dependencies.
Commit both the Gemfile and Gemfile.lock file to your repository
Deploy both the Gemfile and Gemfile.lock to your production servers to ensure that they're running the exact same dependencies as your development environment.
Running bundle update by itself can be construed as dangerous that will update all the dependencies of your application. It's mainly dangerous if you don't have solid version numbers specified in the Gemfile. I wrote about it here.
FWIW I had this problem and fixed it by removing some conditional statements from my Gemfile (conditionals on OS) and rerunning bundle.
FYI: You can also get this error if you use source blocks like this:
source 'https://rails-assets.org' do
gem 'rails-assets-jquery'
end
You'll see an exclamation point in the Gemfile.lock for this gem:
rails-assets-jquery!
Just define the additional source normally, i.e.
source 'https://rails-assets.org'
gem 'rails-assets-jquery'
(BTW cf. here about using multiple gem sources.)
This can be caused by an old version of the bundler gem on the server you're deploying to (in this case production). Logging into the server and running a gem update bundler resolved the issue for me. The server I was deploying to was running version 1.7.4 and the current version was 1.9.
I had an issue with my production server still using an old version of a gem, even though the Gemfile.lock showed the correct, updated version. My production server was running on Unicorn - and shutting down / starting it back up again fixed the issue - instead of sending the HUP signal, which did jack all to fix the issue.
bundle install failed on my "development" machine because of the mysql-gem on osx...
I also needed a quick fix. So I cloned the repo to a new folder on the production machine, ran "bundle install" there and committed the Gemfile.lock to the repo.
I have had this problem (Ubuntu 12.10 & 12.04, one of which behind a proxy server).
My problem was that I had some git:// protocols in the Gemfile. Changing this to http:// helped me get it all working.