I am using rvm, ruby 2.0.0 and bundler.
My Gemfile looks like this:
source 'https://rubygems.org'
gem 'logger'
gem 'mygem', :path => '.'
bundle installs both of them gems. bundle show shows logger is installed in ~/.rvm/gems/ruby-2.0.0-p247/gems, but mygem is installed in the path where the gem is located.
Is there any way to get bundle to install the local gem into rvm's gems directory?
No, Bundler treats path gems differently and does not install them to your GEM_PATH. This is so that you don't need to reinstall as you make changes.
It is not normal or necessary for a gem to point to itself or its runtime dependencies in its Gemfile. You might want to add gemspec to do this automatically. See http://bundler.io/v1.3/rubygems.html
Related
I'm trying to follow a guide to use rspec for testing. I use bundle init to create the Gemfile. Then I tried to do bundle install (following the guide) to install all the gems. I made sure to be in the same folder containing the gemfile. However, I keep getting this:
The Gemfile specifies no dependencies
Bundle complete! 0 Gemfile dependencies, 1 gem now installed.
Use bundle info [gemname] to see where a bundled gem is installed.
My Gemfile (right after I did bundle init) looks like this:
frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "rails"
I use ruby 2.7.1.
Any help will be greatly appreciative.
I tried this step by step and I get this error only when I haven't specified any gem in my Gemfile. I guess the bundle init command create a Gemfile with gem 'rails' line is commented. Please verify your Gemfile and make sure you have added at least one gem into your Gemfile or check if gem 'rails' line is still commented out.
I'm moving some ruby projects over to an Ubuntu machine, and am trying to install the dependencies.
I've installed ruby-full and the bundler gem. When I move to the project directory and type bundle install I get the error Could not locate Gemfile
I am in the correct directory, and the GemFile is there.
If I ls the current directory, I see:
etrax_connect.rb fujixml.bat fuji_xml.rb GemFile GemFile.lock generate_subject_xml.rb logging.rb prawn_functions.rb README.md samples sftp_connect.rb
Its RIGHT there.
The contents of my GemFile:
source 'https://rubygems.org'
gem 'listen'#file listening
gem 'nokogiri'#xml parsing
gem 'rake'#Globbing
gem 'net-sftp'
gem 'tiny_tds'
gem 'prawn'
I dont understand.
Rename GemFile to Gemfile, and also GemFile.lock to Gemfile.lock.
I want to add code coverage to my project and sign up coveralls.io and create Gemfile with:
gem 'coveralls', require: false
but how can I install the gem from Gemfile?
run the command bundle install in your shell, once you have your Gemfile created.
This command will look your Gemfile and install the relevant Gems on the indicated versions.
The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.
Your can create a Gemfile just by typing bundle init in your shell
I add a Gemfile example for your reference:
source "https://rubygems.org" # where gems will be downloaded from
ruby "2.2.3" # ruby version, change for the one you use
gem "sinatra"
gem "sinatra-flash"
gem "sinatra-partial"
gem "bcrypt"
gem "dm-validations"
gem "dm-transactions"
gem "data_mapper"
gem "dm-postgres-adapter"
gem "pg"
gem "database_cleaner"
group :test do # you can make groups for test, development, production..
gem "rspec"
gem "capybara"
gem "rspec-sinatra"
gem "cucumber"
gem "coveralls", require: false
end
First install bundler if you don't have it
gem install bundler or sudo gem install bundler if you don't have the required permissions. Bundler is a gem that manages gem dependencies.
then you can follow the above instruction for creating the gemfile, after which you can issue the command
bundle install
I cannot require a custom gem I developed to a ruby project. I use RVM. Here's what I've done:
I added gem locally via Gemfile:
gem 'my-gem', git: 'https://github.com/username/my-gem.git'
I installed the gem:
bundle
Fetching https://github.com/username/my-gem.git
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Using my-gem 0.1.0 https://github.com/username/my-gem.git (at master#dcdac02)
Using bundler 1.11.2
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
I confirmed it was installed:
bundle show my-gem
/Users/myuser/.rvm/gems/ruby-2.2.2/bundler/gems/my-gem-dcdac02a8b69
I confirmed my gem paths:
GEM PATHS:
- /Users/myuser/.rvm/gems/ruby-2.2.2
- /Users/myuser/.rvm/gems/ruby-2.2.2#global
When I run gem list, my gem is missing. When I require 'my-gem', the gem cannot be found.
When I run gem which my-gem, I get:
ERROR: Can't find ruby library file or shared library my-gem
I'm not really sure what else to try. Any ideas?
Rubygems have no concept of git installed gems, so Bundler includes a specific mechanism for loading these paths into the GEMPATH, you need to do the following before you can require them:
require 'bundler'
Bundler.setup
See the Bundler git gems docs for more info.
I would make sure the installed version of the gem has all the files you expect, especially lib and its contents. This past discussion might help you:
gem which cannot find gem despite it being installed
I found a similar issue
bundle show kubernetes_metadata_filter
/fluentd/vendor/bundle/ruby/2.3.0/bundler/gems/fluent-plugin-kubernetes_metadata_filter-0cd7e29eacec
while the rest of my gems were install here:
/fluentd/vendor/bundle/ruby/2.3.0/gems/
notice the subtle difference between 2.3.0/bundler/gems/... and 2.3.0/gems/......
HACKY SOLUTION:
after bundle install, i did the following:
gem install specific_install
gem specific_install -l <url to a github gem>
That did the trick and installed the gem to the gems directory, and not just bundler. I beleive the correct fix is the project needs to require bundler on startup, then it will get the bundler installed gems as well, but not all projects are well suited for that solution. good luck!
After adding
gem "ransack", :git => "git://github.com/ernie/ransack.git"
to my gemfile, I now get the error message :
git://github.com/ernie/ransack.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
for any rails <>, bundle, or gem command.
This is with bundler version 1.0.21.
I see there is now version 1.30 on github, but the install "instructions" on the bundler site, seem to imply that it using an existing bundler to set up the new version?
http://gembundler.com/
require "rubygems"
require "bundler"
Bundler.setup(:default, :ci)
require "nokogiri"
How can I un-install the existing (broken) bundler, and install the new version, without an older version present ?
Mike
Bundler is just a gem like any gem, and there is no need to use Bundler to install Bundler, regardless of what the instructions tell you. It's as simple as:
gem uninstall bundler
gem install bundler
If you are using RVM, there may be a little more to it than this (you may have to switch to the 'global' gemset first), but not much.