Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compass from RVM gemset #49

Closed
michaek opened this issue May 7, 2013 · 18 comments
Closed

Compass from RVM gemset #49

michaek opened this issue May 7, 2013 · 18 comments

Comments

@michaek
Copy link

michaek commented May 7, 2013

Do you know of a way to convince Grunt to use the binaries from an RVM gemset instead of system Ruby binaries?

I'm attempting to use my Gemfile/gemset to manage Compass-related dependencies, but my Grunt task is consistently invoking the compass installed with the system Ruby. (From my login shell, all works as expected.)

Thanks!

@sindresorhus
Copy link
Member

bundleExec?

@michaek
Copy link
Author

michaek commented May 8, 2013

Yep, tried that. Bundler asks for the right gems, but they're not there.

On Tuesday, May 7, 2013, Sindre Sorhus wrote:

bundleExec https://github.com/gruntjs/grunt-contrib-compass#bundleexec?


Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-17577726
.

@michaek
Copy link
Author

michaek commented May 9, 2013

I think part of the issue would be convincing grunt.util.spawn to open a login shell. The second part would be allowing us to execute an "rvm use ..." command before our compass command. I don't know how to accomplish either of these, alas.

@robwierzbowski
Copy link
Contributor

Is it a matter of running bundle install to get the correct gems for your machine? I think grunt-contrib tasks assume that if you're setting bundle exec you're using some external task to build and install from a Gemfile.

@michaek
Copy link
Author

michaek commented Jun 5, 2013

Sorry that I missed your question, @robwierzbowski. No, the problem isn't running bundle install - I don't think it has anything to do with bundler, actually.

The issue is with using the right ruby & gemset as specified by RVM configurations.

@michaek
Copy link
Author

michaek commented Jun 5, 2013

@sindresorhus, I don't think this issue should be closed, unless you're explicitly planning not to support RVM for Compass and related gems.

@robwierzbowski
Copy link
Contributor

It's odd that things work differently in a shell prompt and with Grunt, since basically Grunt is spawning a process that runs shell commands. Can you give some example input/output/errors?

@michaek
Copy link
Author

michaek commented Jun 5, 2013

I agree that it's odd, but RVM requires a login shell for some of its magic, and the shell that Grunt spawns isn't a login shell, as far as I can tell. I'll hit you up with some examples as soon as I can!

@sindresorhus sindresorhus reopened this Jun 5, 2013
@jackmcpickle
Copy link

Any updates on this?

@peschee
Copy link

peschee commented Aug 27, 2013

As a workaround, for now, you can use https://github.com/sindresorhus/grunt-shell to compile compass / sass files while taking your RVM into account. E.g.

        shell: {
            options: {
                stdout: true,
                stderr: true
            },
            compass: {
                command: 'compass compile -e production --force'
            }
        },

@sindresorhus
Copy link
Member

@peschee I don't see how using grunt-shell is any different. Both uses child_process.

@shadowmint
Copy link

Just hit this issue myself, very annoying.

@mcalthrop
Copy link

Ditto. Is there any way of setting the ruby version so that I can run bundle install?

I'm currently getting the following error when I set up a shell task for the above command:

Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

@michaek
Copy link
Author

michaek commented Jan 22, 2014

I know this is one of those unsatisfying StackOverflow-style use-this-not-this answers, but I stopped using RVM in favor of chruby, as it's much simpler and doesn't have the "bad behavior" associated with RVM (messing with cd, etc).

Combining chruby with the bundleExec option on grunt-contrib-compass satisfies the requirements that I'm aware of. The environment variables set by chruby carry over to the child process, and the Gemfile specifies which gem versions are used (of those installed). Keep in mind that bundleExec is false by default.

@michaek
Copy link
Author

michaek commented Jan 22, 2014

An example for folks to test with: https://gist.github.com/michaek/8557774

@mcalthrop
Copy link

Thanks Michael.

A colleague also recommended rbenv. Looks good, and is written by Sam Stephenson, so I expect it's solid.

Haven't had a chance to test it yet though.

@michaek
Copy link
Author

michaek commented Feb 4, 2014

For the record, I reinstalled the current RVM this morning, and I was not able to reproduce this issue. I can't say what brought about the change: new RVM, new grunt-contrib-compass, or a user error that I resolved unknowingly. Regardless, I'm going to close this unless there's confirmation that RVM is still not working in grunt child processes.

@michaek michaek closed this as completed Feb 4, 2014
@yaron-idan
Copy link

Hi, I have a similar problem to what described here, and I wanted to know if any of the people who posted here encountered it (and hopefully overcome it).
When running grunt with compass and rvm, as described in the original issue, and it works fine.
However, I'm in the process of writing our server configuration in Ansible, and when running the commands as an Ansible playbook I'm getting an error since the playbook calls the system-wide instance of rvm, and not the one used to install compass.
Is there anyway to direct grunt-contrib-compass to use a specific RVM and not the system's default one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants