In my gem file I have a Git reference:
gem "calendar_date_select", :git => 'git://github.com/paneq/calendar_date_select.git'
I would like to know where bundler paced that Git checkout so I can manually clean it.
Thanks.
this depends on your local setup. let me explain by one of my projects.
it's within an rvm gemset, so my .rvmrc is like this:
rvm use ruby-1.9.3-p125#hamburg_on_ruby --install --create
and i use ActiveAdmin from git in my Gemfile
gem "activeadmin", :git => "https://github.com/gregbell/active_admin.git"
which results in a Gemfile.lock like this
GIT
remote: https://github.com/gregbell/active_admin.git
revision: 82a13de45feeba2510f015aaae9d412878e4c6f5
so the actual cloned repo is in
~/.rvm/gems/ruby-1.9.3-p125#hamburg_on_ruby/bundler/gems/active_admin-82a13de45fee/
Related
Currently, Rails' Github master is on version 6.1.0-alpha. However, this version is not available through Rubygems.
> gem search ^rails$ --pre
*** REMOTE GEMS ***
rails (6.0.3.rc1, 6.0.2.rc2, 6.0.2.rc1, 6.0.1.rc1, 6.0.0.rc2, 6.0.0.rc1, 6.0.0.beta3, .......)
Is there a way to force a gem to be installed with the latest commit through Rubygems.org without using Bundler? Something like Homebrew's devel or the example below would be ideal:
gem install rails --head
When I need to use a head of gem, I just use through Github source like this.
gem 'rails', github: 'rails/rails', branch: 'master'
Since this version is not released on Rubygems yet, I don't know is there a way to use it through RubyGems.
Be aware that installation by Github took long even with fast internet connection.
Is there a way to force a gem to be installed with the latest commit
through Rubygems.org without using Bundler?
The short answer is no, you cannot force-install an unpublished gem through RubyGems.org because RubyGems is a repository for published gems. If the repository owner has pushed a version of the gem to RubyGems you can find and install it. If they haven't, you can't.
If you want to use pre-published code from a repository, use the Bundler method outlined in Semih's answer:
gem 'rails', github: 'rails/rails', branch: 'master'
Per the RubyGems site documentation:
Installing a gem directly from a git repository is a feature of
Bundler, not a feature of RubyGems. Gems installed this way will not
show up when you run gem list.
I downloaded the latest file from github, edited the .gemspec file to require a gem I need; what do I then do to be able to use the gem? Do I have to bundle it with bundler to be able to use it?
Sorry if dumb question, but so confused right now... can't find much info especially on Rapidfire...
You need to fork the repository.
Clone the forked repository and edit the gemspec: git clone git#github.com:code-mancers/rapidfire.git
Commit your changes: git add .; git commit -m "whatever"
Push your changes: git push origin master
Edit the your project's Gemfile pointing the forked gem: gem 'rapidfire', github: 'your-user/rapidfire', branch: 'master'
You can do:
gem build path-of-the-gemspec-file
Then
gem install path-of-generated-gem-file
For example:
In the root path of your gem, you can do:
gem build my-gem.gempsec
Then:
gem install my-gem-0.1.0.gem
To see if the gem was installed:
gem list | grep my-gem
When I try to run bundle install using this in my Gemfile
gem 'activeadmin', github: 'gregbell/active_admin'
I get :
Fetching git://github.com/gregbell/active_admin.git
Retrying source fetch due to error (2/3): You need to install git to be able to
use gems from git repositories. For help installing git, please refer to GitHub'
s tutorial at https://help.github.com/articles/set-up-git
But I already have git installed, and also I can run git commit, git pull and others command.
I'm on windows 8, using RoR 4
There are two ways to access github, over git:// and http:// you can try over http://
I have this line in my Gemfile, you can adapt it to your needs:
gem 'activeadmin-mongoid', :git => 'https://github.com/piousbox/activeadmin-mongoid.git', :branch => 'fix_sidebar_disable'
So for you maybe
gem 'activeadmin', :git => 'https://github.com/gregbell/active_admin.git'
Also, I assume you do have git installed? Because the error says, install git ; )
sudo apt-get install git if you are on ubuntu, or
brew install git if you are on Mac OS X.
I'd like Bundler to load a local gem. Is there an option for that? Or do I have to move the gem folder into the .bundle directory?
I believe you can do this:
gem "foo", path: "/path/to/foo"
In addition to specifying the path (as Jimmy mentioned) you can also force Bundler to use a local gem for your environment only by using the following configuration option:
$ bundle config set local.GEM_NAME /path/to/local/git/repository
This is extremely helpful if you're developing two gems or a gem and a rails app side-by-side.
Note though, that this only works when you're already using git for your dependency, for example:
# In Gemfile
gem 'rack', :github => 'rack/rack', :branch => 'master'
# In your terminal
$ bundle config set local.rack ~/Work/git/rack
As seen on the docs.
You can also reference a local gem with git if you happen to be working on it.
gem 'foo',
:git => '/Path/to/local/git/repo',
:branch => 'my-feature-branch'
Then, if it changes I run
bundle exec gem uninstall foo
bundle update foo
But I am not sure everyone needs to run these two steps.
In order to use local gem repository in a Rails project, follow the steps below:
Check if your gem folder is a git repository (the command is executed in the gem folder)
git rev-parse --is-inside-work-tree
Getting repository path (the command is executed in the gem folder)
git rev-parse --show-toplevel
Setting up a local override for the rails application
bundle config local.GEM_NAME /path/to/local/git/repository
where GEM_NAME is the name of your gem and /path/to/local/git/repository is the output of the command in point 2
In your application Gemfile add the following line:
gem 'GEM_NAME', :github => 'GEM_NAME/GEM_NAME', :branch => 'master'
Running bundle install should give something like this:
Using GEM_NAME (0.0.1) from git://github.com/GEM_NAME/GEM_NAME.git (at /path/to/local/git/repository)
where GEM_NAME is the name of your gem and /path/to/local/git/repository from point 2
Finally, run bundle list, not gem list and you should see something like this:
GEM_NAME (0.0.1 5a68b88)
where GEM_NAME is the name of your gem
A few important cases I am observing using:
Rails 4.0.2
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
Ubuntu 13.10
RubyMine 6.0.3
It seems RubyMine is not showing local gems as an external library. More information about the bug can be found here and here
When I am changing something in the local gem, in order to be loaded in the rails application I should stop/start the rails server
If I am changing the version of the gem, stopping/starting the Rails server gives me an error. In order to fix it, I am specifying the gem version in the rails application Gemfile like this:
gem 'GEM_NAME', '0.0.2', :github => 'GEM_NAME/GEM_NAME', :branch => 'master'
You can reference gems with source:
source: 'https://source.com', git repository (:github => 'git/url')
and with local path
:path => '.../path/gem_name'.
You can learn more about [Gemfiles and how to use them]
(https://kolosek.com/rails-bundle-install-and-gemfile) in this article.
If you want the branch too:
gem 'foo', path: "point/to/your/path", branch: "branch-name"
I have such lines in Gemfile:
group :test do
...
gem 'cucumber', :git => "git://github.com/aslakhellesoy/cucumber.git"
...
end
When I try do deploy on server via bundle install --deployment --quiet --without development test, I get an error:
sh: git: command not found
** An error has occurred in git when running `git clone "git://github.com/aslakhellesoy/cucumber.git" "/home/test/rails_apps/test_app/shared/bundle/ruby/1.8/cache/bundler/git/cucumber-3eb3f1a09813a1271fada66aac31d953ef2ad625" --bare --no-hardlinks. Cannot complete bundling.
I have no git executable on server. But I don't want to use git because cucumber in :test group, and I execute bundler with "--without test"!
What should I do?
There are no way to do this. Because this is feature of bundler
Note that on bundle install, bundler
downloads and evaluates all gems, in
order to create a single canonical
list of all of the required gems and
their dependencies. This means that
you cannot list different versions of
the same gems in different groups. For
more details, see Understanding
Bundler.
http://gembundler.com/man/gemfile.5.html (see GROUPS part)
What about you haven't git or any gems at your server. You should use bundle pack. But, now bundle pack don't work with git. Then you should pack git sources manually:
cd vendor/git
git clone git://github.com/foo/foo.git
Then, in your Gemfile,
gem "foo", :path => "vendor/git/foo"
.
http://github.com/carlhuda/bundler/issues/labels/git#issue/67