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

Rack gem installation & Middleman commands have Ruby version conflict #2041

Closed
davedub opened this issue Jan 20, 2017 · 5 comments
Closed

Rack gem installation & Middleman commands have Ruby version conflict #2041

davedub opened this issue Jan 20, 2017 · 5 comments

Comments

@davedub
Copy link

davedub commented Jan 20, 2017

On a default install, I can't set-up a Middleman 4.2 project that runs Rack and also is able to use the 'middleman' commands. The problem is that Rack requires Ruby >= 2.2.2, but Middleman commands only exist for 2.1.0 and 2.2.0.

Steps to reproduce the problem (from a clean middleman installation)

Run bundle install where the option to include Rack has been selected, with local Ruby version set at 2.2.0, this message appears:

Gem::InstallError: rack requires Ruby version >= 2.2.2.
An error occurred while installing rack (2.0.1), and Bundler cannot continue.
Make sure that gem install rack -v '2.0.1' succeeds before bundling.

Switch .ruby-version over to 2.2.2:

~/projects/project_name $ rbenv local 2.2.2

Now all gems get installed.

Bundle complete! 7 Gemfile dependencies, 52 gems now installed.

But I can then no longer use "middleman" commands:

~/projects/project_name $ middleman build

Which replies -

rbenv: middleman: command not found

The middleman command exists in these Ruby versions:
2.1.0
2.2.0

Any chance you will update soon to make this work more smoothly?

Additional information

  • Ruby version: 2.2.0, 2.2.2
  • Middleman version: 4.2
  • OS version: Mac OS X 10.12.2
@aturkewi
Copy link

Hey @davedub it sounds like you need to have a different set of gems for each ruby version. To get the command to work, you'll just need to install middleman on Ruby 2.2.2 with gem install middleman

@davedub
Copy link
Author

davedub commented Jan 24, 2017

Appreciate the tip, @aturkewi, but I am not sure I see this as being the problem I am running into. I set up a new project and make sure 2.2.2 is running locally.

~ $ cd Projects
~/Projects $ mkdir project_name
~/Projects $ cd project_name
~/Projects/project_name $ rbenv local 2.2.2
~/Projects/project_name $ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin16]

Then I check which gems are installed:

~/Projects/project_name $ gem list middleman

*** LOCAL GEMS ***

contentful_middleman (1.5.0)
middleman (4.2.0)
middleman-blog (4.0.1, 3.5.3)
middleman-cli (4.2.0)
middleman-compass (4.0.1)
middleman-core (4.2.0)
middleman-deploy (2.0.0.pre.alpha, 1.0.0, 0.2.3)
middleman-livereload (3.4.6, 3.3.4, 3.1.1)
middleman-minify-html (3.4.1, 3.3.0)
middleman-s3_sync (3.3.10)
middleman-sprockets (4.1.0, 3.5.0, 3.4.2, 3.4.1)
middleman-syntax (3.0.0)

So it looks like I have local gems inside 2.2.2 , but when I try to use a Middleman command, it still says it's not found:

~/Projects/project_name $ middleman init
rbenv: middleman: command not found

The 'middleman' command exists in these Ruby versions:
2.1.0
2.2.0

@aturkewi
Copy link

Hmm, I'm wondering if this might have to do with how you have your environment setup more so than middleman.

I'm using rvm and when I switched to 2.2.2, I had to install middleman:

// ♥ rvm use 2.2.2
Using /Users/avidor/.rvm/gems/ruby-2.2.2
[18:25:09] middle_man
// ♥ middleman init new-project-2
-bash: middleman: command not found

So I went through and installed middleman:

// ♥ gem install middleman
Fetching: kramdown-1.13.2.gem (100%)
Successfully installed kramdown-1.13.2
Fetching: tilt-2.0.5.gem (100%)
Successfully installed tilt-2.0.5
Fetching: haml-4.0.7.gem (100%)
...
..
.

And then I had no problem creating a new project:

// ♥ middleman init new-project-2
         run  git clone --depth 1 https://github.com/middleman/middleman-templates-default.git
...
..
.

You could try re-intalling them middleman gem or perhaps look into using gemsets? I don't have a ton of experience with rbenv but I think these might yield some solutions for you.

@davedub
Copy link
Author

davedub commented Jan 27, 2017

Hey thanks ... using rbenv gemsets seemed to do the trick.

@davedub davedub closed this as completed Jan 27, 2017
@davedub
Copy link
Author

davedub commented Jan 27, 2017

Actually, in case others get confused by looking at this issue and its apparent resolution, let me clarify. My mistake was that I did not have the Middleman gem installed for 2.2.2, not that I wasn't using rbenv-gemset. When I ran --

$ gem list middleman

-- and I knew the local Ruby version was 2.2.2, the CLI returned a list of the gems with that name that I then presumed were installed for that local Ruby version. Otherwise, I thought it would return an empty set. But apparently not. I saw the gem as installed but it really wasn't. Once I went ahead and again tried to install the middleman gem while 2.2.2 was running locally - gem install middleman -, it showed the gem installing, then showed it as installed, and then I was able to use the "init" and other Middleman commands in 2.2.2 without any problem.

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

2 participants