I've inherited a project that used to have a build script that bundle installed with the --without env flag. Now I need that env.
I removed the --without flag from the build script, but those preferences are cached by bundler in .bundle/config. The build server has some confusing auto-caching of dependencies itself, and I have no idea where the .bundle/config is located.
Is there an bundler invocation capable of unsetting these --without preferences? A --with would be nice.
While undocumented in the bundle install help, bundle config notes you can reset or unset the without flag via bundle config without newenv and bundle config --delete without respectively.
You could always remove the .bundle directory and reinstall. The only reason I'd hesitate to do this is if you have versions of gems that are no longer available. You could always move it first to test:
mv .bundle _bundle
bundle install
If that works, you can remove the temporary _bundle directory, or whatever you've called it.
If it screws up, you can always restore it:
rm -rf .bundle
mv _bundle .bundle
Related
I have a staging server. And I've got some issue I'd like to investigate right there. But I forgot to add byebug to Gemfile. I can surely add it locally, run bundle, commit to repository, deploy. But isn't there an easier way?
When I try to change Gemfile remotely and run bundle I get:
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 /home/gccs/website-backend/releases/20161018143057/Gemfile freeze
by running `bundle install --no-deployment`.
You have added to the Gemfile:
* byebug
Gems are installed with capistrano, basically, like so:
bundle install --path /home/user/app/shared/bundle --without development test --deployment --quiet
Edit .bundle/config changing BUNDLE_FROZEN: '1' to '0' (or removing it) is enough in order to be allowed by Bundler to manage gems in a deployment environment. Then you can edit the Gemfile, run bundle, restart your application and the custom gems are ready to be used.
If you intend to use them outside of the application runtime (f.e. if you need pry in rails console) restarting the server is not needed.
The reason why you're unable to install additional gems is because the bundle is frozen. You can check it like so:
$ grep FROZEN .bundle/config
BUNDLE_FROZEN: '1'
If you remove the line (as suggested by mdesantis) or change "1" to "0", you'll be able to install whatever gems you like, as if it were developer machine. But generally it's best to restore the value, if no more needed. Not sure if bundler will do that automatically on next deploy.
I have a rails app that I'm running locally where the gems are installed in the vendor/bundle directory. I want to add some debugging statements to a gem and then test it locally. I'm running bundle exec rackup config.ru to run the server. I've tried rerunning bundle install before starting the application, but that still doesn't seem to pick up my changes. Any ideas?
Running bundle show --paths will print out exactly where Bundler is loading your gems from, so you can double-check that against the files you are editing.
As a shortcut, bundle open <gemname> will open that gem's directory in your editor of choice (whatever your EDITOR environment variable is set to). You can then edit it directly there.
There is normally no need to re-run bundle install or rebuild the gem when you edit files this way.
I was fiddling around with the --deployment option on my ruby app. After that I wanted to add another gem to my app. I added it to the gemspec, and ran bundle install but the new gem didn't get installed. I deleted the vendor cache, .bundle, Gemfile.lock and tried again, and got the error I expected:
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.
...
I had seen this before, so I proceeded to use --no-deployment flag. For some reason though, the same error popped up again. An hour later I'm still stuck in the same place. No matter what I do, I can't get bundle install to work and install the new gem.
Is this some sort of strange error? Or bundler by design?
Pff... Somehow a .bundle config folder sneaked into my home directory, which made all repos on my machine look like deployment repos to bundler. Deleting the .bundle folder resolved the issue.
You can list the current configurations by running
bundle config list
After that, if deployment is set to true, for instance, just do
bundle config set deployment false
What command is being run when you call bundle? Is it just calling bundle install under the hood?
Just running bundle calls the bundle script with it's last parameter-set.
Suppose, in your project, you initially did bundle install and then changed your Gemfile. To update the gems, you need not repeat bundle install again (though, you still can), you can simply run:
bundle
Similarly, if you initially used bundle install --binstubs (with binstubs flag), using bundle later in the project, will trigger the former command again.
Good luck. :)
I accidentally ran sudo bundle install smtp_mail and now all my gems are in this directory called smtp_mail inside my Rails app.
I'm not sure about the default location of gems? And, my Rails app is complaining when it starts. Is there a way I can revert back?
After a bit of Googling around i was able to find the answer
Just run:
sudo bundle install --system and you'll have your gems back at their appropriate system directories.
The path is specified in a file located in
.bundle/config
If you delete the .bundle directory and then delete your smtp_mail directory you will be back at square one. If you really want a local (to your app) installation of the gems, I recommend you run
bundle install --path vendor/bundle
Good luck!
pay attention on this...
from the bundle man page:
By default, bundler installs gems to the same location as gem install.
You should never use sudo bundle install. This is because several other steps in bundle install must be performed as the current user:
Updating your Gemfile.lock
Updating your vendor/cache, if necessary
Checking out private git repositories using your user's SSH keys
Of these three, the first two could theoretically be performed by chowning the resulting files to $SUDO_USER. The third, however, can only be performed by actually invoking the git command as the current user. Therefore, git gems are downloaded and installed into ~/.bundle rather than $GEM_HOME or $BUNDLE_PATH.
As a result, you should run bundle install as the current user, and bundler will ask for your password if it is needed to put the gems into their final location.
This helped me when I ran into a simular issue.
I rm -rf all files in .bundle and then removed and then I followed the commands in this document.
http://ruby-korea.github.io/bundler-site/issues.html.