I haven't upgrade my gems for a long time, just today, I decided to run a upgrade. I probably made a mistake at first running bundle install update, which didn't do anything. Then I ran bundle update, and it created a whole new folder called update in my rails directory containing all the gems, and it seems like my rails project is no longer linked to my rvm gem directory because if I remove the update folder it fuzzes about not being able to find gems. I'm just wondering if this is the new behavior to rails or it's because I did something wrong. Thanks!
Edit:
The output of bundle config is:
Settings are listed in order of priority. The top value will be used.
path
Set for your local app (/Users/X/dev/tasker/.bundle/config): "update"
disable_shared_gems
Set for your local app (/Users/X/dev/tasker/.bundle/config): "1"
This seems to be the problem. So how should I revert it to its state before by linking to the rvm gem directory? And is the problem caused by my 'bundle install update' command? Thanks!
Edit again:
Thanks for the help guys. After finding out the root issue of my problem, I found this solution: bundle install --system at How can I fix an accidental 'sudo bundle install dir_name'?. Now the problem is solved. Thanks!
I made same mistake.
Check command line options for bundle. bundle install accepts directory. and if you type bundle install update, it install the bundle onto the directory.
If you did, bundler create .bundle/config file and store the given path in the file.
I think, just removing .bundle directory and run "bundle" will bundle the needed files,
will use the gems in RVM (if RVM configured correctly).
Related
We have a ruby rails project which we normally get from our enterprise github repository. Recently, I've added dependencies that for some reason breaks my other projects that are not related to the one I was working on. My questions are
Does "bundle install" saves the dependencies globally? or can it behave like the npm to install on current project?
Can I undo "bundle install" by using "bundle clean --force"? after doing this and running "bundle install" again it doesn't to make any changes (not showing "Installing" instead it's say "Using"
I tried removing the the version of ruby since I found out that runing "bundle install" creates a directory /usr/share/rvm/gems/ruby-2.7.2#ruby_test_setup_engine/. But my issue was still there.
I also tried deleting the project folder and cloning it again but since
/usr/share/rvm/gems/ruby-2.7.2#ruby_test_setup_engine/ was created it didn't do anything at all.
Not sure what kind of issues you are facing. but based on your question here is the details:
Does "bundle install" saves the dependencies globally?
No it's not saves globally, it's saved specific to project and more specific to gemset you are using.
Can I undo "bundle install" by using "bundle clean --force"?
No, this command just cleans up unused gems in your bundler directory.
But you can undo your bundle via rvm gemset empty.
Removing gem directory won't help as it will create as soon as you run bundle install command.
Another way to reset you gemset is remove your Gemfile.lock and copy from original source and re run bundle install.
Hope this info will helps.
I use RVM to manage Ruby versions.
In my project I use Bundler to manage gems for the project.
RVM also have gemsets.
Gem in gemset don't have a connection with Bundler's gem. ← Is this correct?
I came to this conclusion because gem files stored in different locations:
RVM gemset: ~/.rvm/gems/ruby-2.0.0-p247#myApp
Bundler: [my_app_dir]/vendor/bundle/gems
So app uses Bundler gems, not RVM gemset gems.
But when I add gem to my Gemfile, RubyMine IDE shows me warning, that this gem is not in RVM gemset. So I add this gem to RVM gemset also (just to get rid of this warning).
So the questions are:
Is there any good reason to add gems in both places (RVM Gemset and Gemfile)?
If no, then why RubyMine warning me about this?
Is there any good reason to add gems in both places (RVM Gemset and Gemfile)?
The gemset is incidental, the Gemfile is absolutely the place to declare your dependencies. Where you store those gems is up to you.
It sounds like Bundler is configured to store them in a project-local path, but you're expecting them to be in a gemset. Bundler got that configuration by running bundle install --path vendor/bundle/gems at some point. It stores that configuration in its project configuration file at project_dir/.bundle/config:
BUNDLE_PATH: vendor/bundle/gems
I'm unfamiliar with Rubymine, but if you run the Rails server using Bundler (i.e. bundle exec rails server) you can ignore that warning. Bundler will correctly load the gems listed in the Gemfile.
If you want to use a gemset instead of the Bundler cache, you can just remove that line from the Bundler configuration file and reinstall your gems with bundle install.
If no, then why RubyMine warning me about this?
My guess is that Rubymine is not reading the Bundler project configuration (in project_path/.bundle/config) and does not understand where the gems are installed.
You (or if you are working in a team, somebody of your team) has once done a bundle install and specified a installation-folder. In your case vendor/bundle/gems. Bundle remembers this setting and all next invocations of the bundle command will use the same path.
There is a good reason to do it that way: your application-folder will contain all requirements and will be easier to redistribute (for instance).
Now if you want that bundle installs your gems in the normal locations, you can do the following:
run bundle install --system which will use the default location
alternatively: bundle stores it settings in a config file, I think .bundle/config and you can
check that one as well. Normally it is not needed, since bundle install --system will set that
correctly again.
then you can safely remove the vendor/bundle/gems folder
No, something's wrong, you shouldn't have anything under vendor/bundle, it should all be under ~/.rvm/gems/ruby-2.0.0-p247#myApp and perhaps ~/.rvm/gems/ruby-2.0.0-p247#global assuming your .rvmrc (or.ruby-version) is setup correctly.
What does "gem env" look like? Also "bundle env"?
So this just took me 3 days, since nothing else I was finding here was helping. I also run multiple projects through RubyMine at the same time (and different versions) so setting my GEM_PATH and launching from command-line doesn't work for me. I use IntelliJ with RM plugin, this should work on RM standalone.
Bundler seems to install custom gems, or gems from custom repos, in a different directory than gems from rubygems, or github.
/Users/YOURUSER/.rvm/environments/ruby-{version}\#yourgemset/bundler/gems
One thing I wasn't able to fix is in the GEMFILE, I have some custom git_sources, and rubymine highlights those and gives me the warning that it cannot find the gem in my bundle (you can ignore this warning; unless the gem doesn't install at all):
gem 'somegem', custom_git:'gituser/repo'
is highlighted and warning is "Gem x cannot be found... in SDK'
However Bundler installed it, and ruby is able to load it.
# TLDR: Steps to have RUBYMine find extra gems, and show up in external libs
vim ~/.rvm/environments/ruby-{your-verion-here}\#{your-gemset}
add the bundler gems path to GEM_PATH entry
export GEM_PATH='/Users/YOURUSER/.rvm/gems/ruby-{version}#yourgemset/bundler/gems:{the rest}'
save the file
Restart RubyMine/IntelliJ, reopen your project (if not open automatically)
Open the Project Structure dialog > Platform SDKs > Choose the GEMSET you're working with
add /Users/YOURUSER/.rvm/environments/ruby-{version}\#yourgemset/bundler/gems to your classpath
Hit OK, then REOPEN the Project Structure Dialog > Project Settings > Project
Your project will likely have no SDK So select the one you're using again and hit OKAY
RM/IJ will now reindex files
You're done, any broken/missing inspection links should now be fixed. And you should be able to introspect into your gems.
In the above instructions that when you run bundle install (from terminal or RM) it works successfully, and that you have RVM correctly setup, and gemset already created
I hope this helps! Let me know if I should clarify anything (happy NYE)
How do I undo bundle package?
I deleted everything in vendor/cache but it is reinstalled there when I run bundle install.
As per this answer: https://stackoverflow.com/a/9471980/219883
You must delete the hidden .bundle directory, then re-run bundle install - otherwise it will continue to add the vendor/cache directory back every time.
But if you just to remove a particular gem, then remove/comment the name of the gem from your project/Gemfile and then run bundle.
To prevent gem files from being added to the vendor/cache directory delete the vendor/cache directory from your project root.
The next time you will run bundle install gems won't create a vendor/cache folder.
Later on in your project if you need the vendor/cache folder all you'll have to do is to create the folder vendor/cache again.
.bundle/config is telling bundler to put things in vendor/cache. Either remove the following two lines from .bundle/config or remove .bundle/config itself.
---
BUNDLE_PATH: vendor/cache
BUNDLE_DISABLE_SHARED_GEMS: '1'
Then run the following command to remove vendor/cache:
rm -rf vendor/cache
The next time you run bundle install you will not have this problem.
$ rm vendor/cache -r
$ bundle install
This might help as well. For more details see the documentation on bundle install
bundle install --system
Pretty late to answer, but this was happening with me too. You probably have hidden directory .bundle in you application root directory. Remove that directory too and then run bundle command.
You can check your config with (under your project directory):
bundle config
it outputs something like:
Set for the current user (/Users/user/.bundle/config):
"--with-cppflags=-I/usr/local/opt/openssl/include"
In the config file you can check your config setting.
If there's no anything strange like:
BUNDLE_PATH: vendor/cache
You can easily remove vendor/cache directory and run bundle install again
In other way just remove the config variable from the file and repeat ^^
P.S. If you met gems storing under your project. It's probably previous developers worked with private repos and to avoid problems with deploy and private repositories, they solved to store the gems under project directory. So just make sure you will not break your deploy after removing the gems dir.
Bundler 1.2 has support for :git and :path but it has to be explicitly enabled like this
bundle package --all
I was trying to fix some garbage that was happening (frustratingly) by updating rubygems yesterday. To fix spork, I typed "bundle install spork" before I realized I hadn't actually typed "gem install spork" and it installed everything in a spork directory within my project folder. I removed that, and tried "bundle install ." which seemed to work. But I just went to do a commit and noticed I now had a ruby directory in my project.
I removed that, but now don't know how to get bundle to go back to installing somewhere outside my project directory. Does anyone know what command will accomplish this?
If you ever accidentally invoke bundle install foo then it will try to install your gems inside a foo directory, and also will set this as your permanent choice in .bundle. So, take a look at .bundle/config and make sure there isn't anything unwanted in there.
Needed to use bundle install --system to get it to revert back to the default directory.
bundle install with no path argument does it for me.
I have a Rails 3rc app on Ruby 1.9.2 that works fine, but Bundler keeps making a folder named "bandsintown" (bandsintown is a gem I use) in my project directory. From what I can tell, the folder has all my gems in it. I'm pretty sure that this never happened before. Is it normal behavior?
I think this might be interfering with running tests. I get a "Command failed with status (1)" error and then it mentions the "bandsintown" folder a few times.
I find it odd that Bundler names the folder "bandsintown" even when I comment out that gem in the gemfile. There's a "ruby" folder in that one, and a "1.9.1" folder inside the "ruby" folder. I don't understand why it says 1.9.1 when I'm using 1.9.2. The 1.9.1 folder has a bin, bundler, cache, doc, gems and specification folder inside of it.
I made a testapp with all the same gems and did a bundle install. It doesn't make a new folder with all my gems in it.
Anyway, my app works fine, but I'd appreciate it if anyone could help me out here. If I left out any need-to-know information, let me know. Thanks.
You are probably running the following command: bundle install bandsintown. That command tells bundler to install gems into the bandsintown subdirectory of your application. In order to install gems, all you need to do is modify your Gemfile and run bundle install.
Bundler will remember the location that you last specified in the .bundle/config file. So, in order to "reset" bundler's memory. In your application's directory, run rm -r .bundle/config.
Then, after updating your Gemfile, simply run bundle install