How to run Bundle after installing? - ruby

I have done
gem install bundle
inside my directory that I have a git repository. But now when I try to run it with
bundle
run bundle
bundle install
it says:
Could not locate Gemfile.
How would I check that it has installed ?

It looks like it installed the gem correctly, however, you need to create a file named Gemfile for bundler to know what gems it should install. This file should be in your project's root. You can create one manually, or run bundle init to have a default one generated.
You can read more about the Gemfile in the docs

Related

tootlcrl error: Could not find concurrent-ruby-1.1.10 in any of the sources

I'm trying to run a tootctl command, but am running into a problem with it not being able to detect the required dependency is not present.
Could not find concurrent-ruby-1.1.10 in any of the sources
I have run bundle install and the gems get installed (or are confirmed already installed), but the command still has trouble not finding the
Using concurrent-ruby-1.1.10
...dozens of other packages
Using rails-settings-cached 0.6.6
Bundle complete! 122 Gemfile dependencies, 225 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Bundled gems are installed into `../vendor/bundle`
then I attempt the command again..
me#mastodon-vm:/var/www/mastodon/bin$ ./tootctl media remove --days=7
Could not find concurrent-ruby-1.1.10 in any of the sources
Run `bundle install` to install missing gems.
me#mastodon-vm:/var/www/mastodon/bin$
but I'm back to the same problem. What is the typical approach to fix this?
Note: I did try to follow the guidance in this SO post, but it broke the entire installation. I was able to save it by replacing Gemfile and Gemfile.lock from Mastodon's source (phew)
Your log shows
Gems in the groups 'development' and 'test' were not installed.
Try to install your Gems with
bundle install --with development test
or run
RAILS_ENV=production tootctl
According to https://rubygems.org/gems/concurrent-ruby/versions/1.1.10 the gem is named "concurrent-ruby". When I run gem install concurrent-ruby, it is installed successfully on my computer.

What does this mean? Could not find command "add" when running 'bundle add'

I get this error Could not find command "add" when I try to run something like bundle add bcrypt_pbkdf --version "<2.0,>=1.0"
I cannot find anything like this online. I tried bundle install, bundle update, gem install bundler, etc, but it didn't work
How do I fix it?
bundle doesn't have a subcommando for adding new gems. To add a new one, open the Gemfile and manually add your new gem into it. Like:
gem bcrypt_pbkdfm, "~> 1.1"
After that, run:
bundle install
It will read your Gemfile, will download the gems and create a new Gemfile.lock with the installed version.
To understand more about the specs of Gemfile visit https://bundler.io/gemfile.html
EDIT
In fact bundle has bundle add command. I've never used, but it seems to achive the same goal as the manual insert.

RVM: Could not locate Gemfile or .bundle/ directory when running $bundle install command

I'm trying to setup RVM on my mac. When I run bundle install in an empty folder (a dummy project folder) I get the following error:
Could not locate Gemfile or .bundle/ directory
Questions:
Do I need to copy any gem files to the dummy project folder? If so, what gems, and where from?
Do I need to install anything else?
You Just need to check whether you are currently in the rails app folder (In most cases) or double check whether you have created the rails app properly.
Here I am trying to execute the command for starting the rails server,
bundle exec rails server
As you can see since I'm not in that folder it cant locate the required gem to start up the service.
And an Error pops up like below
Could not locate Gemfile or .bundle/ directory
To remove just cd into the app folder
cd YourAPPfolder
And run the required rails command again.
You are done. Voila !!
Make sure you are in the project directory before running bundle install. For example, after running rails new myapp, you will want to cd myapp before running bundle install

Is it possible to bundle / install gems from a local cache?

I have bunch of gems on my computer that I want to use in a chef recipe.
I know it is possible to put them in a directory like /tmp/gems and just:
cd /tmp/gems
gem install *.gem
Is it possible to put all gems in one directory where I can install them with bundler without downloading them again?
cd /somedir/my_rails_project
bundle
I want to save bandwidth.
bundle install --local should be what you want. From the bundle-install manpage:
--local
Do not attempt to connect to rubygems.org, instead using just the
gems located in vendor/cache. Note that if a more appropriate
platform-specific gem exists on rubygems.org, this will bypass
the normal lookup.
You can add local directories to your Gemfile (example from the docs):
gem "nokogiri", :path => "~/sw/gems/nokogiri"
Alternatively, you can set up a local Git repository with the gems in it and write a Gemfile like this:
gem "gem1", :git => "file:///tmp/gems",
:branch => "gem1"
Use
bundle package
Locks and then caches the gems into ./vendor/cache.
The package command will copy the .gem files for your gems in the
bundle into ./vendor/cache. Afterward, when you run bundle install,
Bundler will use the gems in the cache in preference to the ones on
rubygems.org.
http://bundler.io/v1.6/bundle_package.html
You can use the BUNDLE_CACHE_PATH configuration key:
cache_path (BUNDLE_CACHE_PATH): The directory that bundler will place cached gems in when running bundle package, and that bundler will look in when installing gems. Defaults to vendor/bundle.
Source: https://bundler.io/v1.16/bundle_config.html#LIST-OF-AVAILABLE-KEYS
In GitLab CI, I defined this value in the environment of runners: "BUNDLE_CACHE_PATH=/cache-ci/bundle", this directory is mounted automatically in CI runners.
Then bundle install will install gems from the cache directory (once cache will be populated).
If you want to use a local cache for the purpose of speeding up bundle install on CI, for example when a docker container is used to run the tests, you could use --path. This will use gems in the given path unless they are not present, otherwise it will download them to that location.
This assumes the CI build can mount a persistent volume inside the docker container. So for example if the CI machine has a directory /var/cache/drone which can be mounted in the docker container as ./cache then you can do:
bundle install --without=development --quiet --path=cache

Bundling local gem (that I'm developing) does not seem to include lib directory (using rvm)

I'm trying to develop a gem locally, and have installed it with Bundler.
My Gemfile looks like this:
source "http://rubygems.org"
gemspec
And my gemspec is a standard gemspec file.
I can install the gem with 'bundle install' in the directory, and i see the local gem and all it's dependencies install:
bundle install
Using rack (1.3.4)
Using tilt (1.3.3)
Using sinatra (1.3.1)
Using {my gem} (0.0.2) from source at .
Using bundler (1.0.21)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
However, when I do a 'gem list', my gem is not included in the list of gems - which is my guess as to why my bin directory does not appear in the path. Is there a way to test a local gem and include it in the list of installed gems using bundler, so that the bin directory properly works?
Easiest way to get rid of bundler: command not found: {your bin executable}:
git add bin/* # git-ls-files will now list your bin executables.
bundle install
# No git-commit necessary.
bundle exec <MY_BIN_EXECUTABLE>
gem list shows your system installed gems, not the gems in your Bundle (this are often the same but not always--as in this case). When you're using Bundler, you should always execute gem executables with bundle exec so that Bundler can set up the environment for you. So, if you have a binary called, for example, mygem, you should use bundle exec mygem.
See more info at Bundler's site or in the manpage.
[Edit]
Also be sure that your gemspec includes a bin directory! Common convention is to create a directory called bin at the same level as your lib directory, put your binaries in there, and then add this as the directory in your gemspec. If you don't do this, Bundler won't expose your binaries!
I had this problem too.
Make sure the executables and default_executable lines don't contain 'bin/'. Then:
git add add . # You can be more precice if you want.
git commit -m "My lousy commit message."
bundle install
bundle exec <binaryname>

Resources