0

I have been using rbenv for ruby for a while, and I have not had a problem with files being tracked; everything seems to be in it's place, and I haven't really had an issue.

I recently switched to rvm for a new project, and had to change a couple things to my environment. As a result, whenever I now run bundle, all of the gems that were added to my project become tracked via git looking something like this;

new file:   vendor/bundle/ruby/2.2.0/bin/aws-rb
new file:   vendor/bundle/ruby/2.2.0/bin/byebug
new file:   vendor/bundle/ruby/2.2.0/bin/erubis
new file:   vendor/bundle/ruby/2.2.0/bin/geocode
new file:   vendor/bundle/ruby/2.2.0/bin/nokogiri
new file:   vendor/bundle/ruby/2.2.0/bin/rackup
new file:   vendor/bundle/ruby/2.2.0/bin/rails
new file:   vendor/bundle/ruby/2.2.0/bin/rake
new file:   vendor/bundle/ruby/2.2.0/bin/rdoc
new file:   vendor/bundle/ruby/2.2.0/bin/ri
new file:   vendor/bundle/ruby/2.2.0/bin/sass
new file:   vendor/bundle/ruby/2.2.0/bin/sass-convert
new file:   vendor/bundle/ruby/2.2.0/bin/scss
new file:   vendor/bundle/ruby/2.2.0/bin/sdoc
new file:   vendor/bundle/ruby/2.2.0/bin/sdoc-merge
new file:   vendor/bundle/ruby/2.2.0/bin/spring
new file:   vendor/bundle/ruby/2.2.0/bin/sprockets
new file:   vendor/bundle/ruby/2.2.0/bin/thor
new file:   vendor/bundle/ruby/2.2.0/bin/tilt
new file:   vendor/bundle/ruby/2.2.0/bin/unicorn
new file:   vendor/bundle/ruby/2.2.0/bin/unicorn_rails
new file:   vendor/bundle/ruby/2.2.0/cache/actionmailer-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/actionpack-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/actionview-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/activejob-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/activemodel-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/activerecord-4.2.6.gem
new file:   vendor/bundle/ruby/2.2.0/cache/activesupport-4.2.6.gem

and because of this, github doesn't display the entirety of my commits, my git add's take forever, overall it's just very messy.

With rbenv I did not have this problem, so I can only assume it's something to do with how I set up rvm. Here's my current bash_profile

# Set architecture flags
export ARCHFLAGS="-arch x86_64"

# Ensure user-installed binaries take precedence
export PATH=/usr/local/bin:/usr/local/sbin:$PATH

# RBENV - add bin and shims to path
export PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"

# Bash completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
fi

# Git completion
if [ -f ~/.git-completion.bash ]; then
    source ~/.git-completion.bash
fi

# Aliases
alias b="bundle exec"
alias t="RAILS_ENV=test"
alias bi="bundle install; rbenv rehash"
alias bu="bundle update; rbenv rehash"

# message from RVM (5/2/16)
# first attempt below
#source /Users/username/.rvm/scripts/rvm
# next attempt below
source ~/.rvm/scripts/rvm

I believe this current tracking is due to how my path's are set up, and that is something I do not know too much about currently.

I was wondering if anyone has had some experience with this, if they could tell me how I could stop all of the gems I download from being tracked by git. Any help would be appreciated :)

here's my .bundle/config file

---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: true

here's the output of rvm env

export PATH="/Users/username/.rvm/gems/ruby-2.2.3/bin:/Users/username/.rvm/gems/ruby-2.2.3@global/bin:/Users/username/.rvm/rubies/ruby-2.2.3/bin:$PATH"
export GEM_HOME='/Users/username/.rvm/gems/ruby-2.2.3'
export GEM_PATH='/Users/username/.rvm/gems/ruby-2.2.3:/Users/username/.rvm/gems/ruby-2.2.3@global'
export MY_RUBY_HOME='/Users/username/.rvm/rubies/ruby-2.2.3'
export IRBRC='/Users/username/.rvm/rubies/ruby-2.2.3/.irbrc'
unset MAGLEV_HOME
unset RBXOPT
export RUBY_VERSION='ruby-2.2.3'

here's the output of which ruby

/Users/username/.rvm/rubies/ruby-2.2.3/bin/ruby

James N
  • 523
  • 1
  • 8
  • 30
  • I think it's a bundler local/per project configuration. Could you share what you have in .bundle/config? – rgo May 05 '16 at 07:54
  • Did you uninstall rbenv first? There are still some rbenv specific lines in your `bash_profile`. – spickermann May 05 '16 at 07:57
  • 1
    may be duplicated http://stackoverflow.com/questions/19961821/why-bundle-install-is-installing-gems-in-vendor-bundle – jack-nie May 05 '16 at 09:19
  • @rgo I just added my `.bundle/config` – James N May 05 '16 at 16:23
  • @spickermann no, because `rvm` is being used for work, and up to this point I've always used `rbenv` and I've never had a problem. I could switch to `rvm` entirely, but I'm not sure if that is necessary or not – James N May 05 '16 at 16:33
  • Why do you think you have to switch? I worked in several teams in which some developers were using rbenv and others were using RVM. What is the reason that you cannot continue using rbenv in that project? – spickermann May 05 '16 at 16:38
  • @spickermann I'll talk to my boss today and ask. When getting my environment set up they provided a wiki and mentioned they use `rvm`. I didn't think it was that big of a deal, nor did I want to go against the grain so I complied. If I do, do you have an idea of how to delete `rvm` entirely? – James N May 05 '16 at 16:41
  • According to http://stackoverflow.com/a/8104422/2483313 `BUNDLE_DISABLE_SHARED_GEMS` configures bundler to use the `.bundler` folder. Did you try to remove that setting or to set it to `false`? – spickermann May 05 '16 at 16:44
  • I have just set it to `false`. I will make a couple commits, and see what happens. – James N May 05 '16 at 16:51
  • @james-n remove .bundle/config, with these options you're saying install gems in vendor/bundle and do it despite it exists in your system. – rgo May 05 '16 at 17:04
  • @rgo do you mean remove `.bundle/config` in the project, or is there a way to do it globally? I removed the .bundle/config in the current repo, and when I went to bundle, it installed that folder again! I then got the message `Your user account isn't allowed to install to the system Rubygems. You can cancel this installation and run: bundle install --path vendor/bundle` which is what I ran originally when setting up my system. I entered my password (to not run the --path option) and it looks like that might have been the problem. It appears to be back to normal now. – James N May 05 '16 at 17:09
  • 1
    @JamesN If you run this command you're configuring this project to install gems there. It gives me a clue what happened with your rvm install, could be possible that you messed it up with sudo previously? Could you say me if your user has the ownership of ~/.rvm and ~/.gem? If it is not then you should chown them – rgo May 05 '16 at 20:58
  • 1
    @JamesN another idea if previous one doesn't work, maybe it's using system rubygem as a fallback because bundler it is not installed: gem install bundler – rgo May 05 '16 at 21:02
  • @rgo ya it looks like the above comment I made was incorrect: it is still tracking the files in git. But yes, my user does have access to both gem and rvm directories. I also installed bundler in my user, but I'm not sure if that worked/fixed it either. – James N May 05 '16 at 21:56
  • @JamesN to try bundler remove first vendor/bundle content (to ensure whether gems are installed there again or not). After this, could add the output of "rvm env"(or info I don't remember, sorry) and "which ruby" commands? – rgo May 06 '16 at 10:08
  • @rgo I added the output of those 2 commands in the question – James N May 06 '16 at 16:40

2 Answers2

0

You should add a .gitignore file.

mastov
  • 2,942
  • 1
  • 16
  • 33
jack-nie
  • 736
  • 6
  • 21
  • 1
    You can "bypass" the problem using it but the real problem is not solved. The problem is that gems are being installed in vendor and it shouldn't be there in development. – rgo May 05 '16 at 08:32
  • i do have a `.gitignore` file, but like @rgo said I feel like that's putting a bandaid on something that I want to fix – James N May 05 '16 at 16:23
0

You have to remove .bundle/config (It's a per project configuration that overrides your user preferences).

Ensure you are using right Ruby's version ($rvm list rubies will show your current Ruby version used in this current path)

If you're using the required Ruby version for the project then you should have installed bundler gem for this Ruby version and it should be work.

rgo
  • 306
  • 2
  • 9
  • thanks for the help, and it looks like that was it. I still have `rbenv` on my system, but for work purposes I'm using rvm. right now everything is running fine :) – James N May 09 '16 at 16:45
  • @JamesN You're welcome. BTW If I don't remember badly .ruby-version files compatible with rvm and rbenv. Maybe you don't need rvm at all. – rgo May 09 '16 at 23:26