2

I'm looking for a way to set up my rails app/Gem file to conditionally include a gem based on if I am in linux or not. I need the app in Linux, but it is not compatible with windows and I don't need it there anyway.

I was able to get everything working on Linux, but since I am using LESS stylesheets, I needed a javascript runtime. I didn't want to install Node.js, so i installed therubyracer, which is now in my gemfile. Then I pushed everything to github and cloned the app on my windows computer.

I tried to install all of the gems and realized there was no way install therubyracer on windows because of an incompatibility they haven't fixed yet (see therubyracer gem on windows)

I read elsewhere that I don't need therubyracer on windows because rails will automatically pick up the JScript runtime, so I'd like to have a simple way to only include therubyracer in linux. I read in does using ":platforms =>" in your gemfile work? that I can use an if block in my gemfile, but that it will cause my gemfile.lock to be regenerated every time. That was over a year ago though. Is there a way to only include therubyracer without regenerating gemfile.lock every time? Or maybe is gemfile.lock ok to remove my git and just have it generated every time locally?

4

1 回答 1

1

I think you'll probably have to use that answer in the :platforms question and just ignore the fact that the gemfile.lock is regenerated. There's not much point in keeping the lockfile in your repository when it will be different on each platform. However, you can still maintain some of the control that the lockfile provides by manually specifying specific versions and dependencies in the gemfile.

于 2013-03-30T03:41:58.977 回答