I just installed Ruby and Middleman for the first time and I cannot get past the very first "$ middleman init my_new_project" step. I have tried Googling for solution to my problem but unfortunately I couldn't find anything that looks like the error I'm encountering.
I hope someone can help me out.
OS: Windows 10 |
Ruby: 2.2.3 (x64) (tried Ruby 2.1.7 first) |
Middleman: 4.0.0
This is the error message I'm getting when I try to create a new project in a folder I created to try out Middleman:
run git clone --depth 1 git://github.com/middleman/middleman-templates-default.git C:/Users/Lenovo/AppData/Local/Temp/d20160120-1612-c2sqbk from "."
exist new_project_test
run bundle install from ".new_project_test"
Could not locate Gemfile or .bundle/ directory
This just creates an empty "new_project_test" folder.
Screenshot of the command prompt: middleman init not working (alt. image link)
What happens if you just run 'middleman init'?
You can also try to create the Gemfile manually, if it's not getting created on the first step, then run init again. The default one would look like this:
# If you do not have OpenSSL installed, update
# the following line to use "http://" instead
source 'https://rubygems.org'
gem "middleman", "~>3.4.1"
# Live-reloading plugin
gem "middleman-livereload", "~> 3.3.0"
# For faster file watcher updates on Windows:
gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw]
# Windows does not come with time zone data
gem "tzinfo-data", platforms: [:mswin, :mingw, :jruby]
Related
I'm currently facing an error when trying to use a gem from GitHub. I have the following in my Gemfile:
# Gemfile
source 'https://rubygems.org'
ruby '2.3.1'
gem 'sinatra'
gem 'rack'
gem 'puma'
group :development do
gem 'byebug'
gem 'rack-test'
gem 'rerun', github: 'alexch/rerun', branch: 'master'
end
When I run bundle install from Dockerfile it works with a message like:
...
Installing sinatra 1.4.6
Installing listen 3.1.5 (was 3.0.6)
Using rerun 0.11.0 from git://github.com/alexch/rerun.git (at master#3e4c486)
Bundle complete! 6 Gemfile dependencies, 14 gems now installed.
...
However, when I go to start the container I get:
The git source git://github.com/alexch/rerun.git is not yet checked out. Please run `bundle install` before trying to start your application
I've seen similar issues but not related to Docker.
Turns out I was able to find the issue. The problem was related to my Gemfile being used to build the Docker image.
I had not locally run a bundle install command which led to the Gemfile.lock not being updated. Once I ran the command the following was added to my Gemfile.lock:
## -1,14 +1,20 ##
+GIT
+ remote: git://github.com/alexch/rerun.git
+ revision: 3e4c486304be406cb86180ef70ec24e9ae055ce4
+ branch: master
+ specs:
+ rerun (0.11.0)
+ listen (~> 3.0)
Turns out that was all I needed. Once I had the updated file, rebuilt the image and ran the container everything worked as expected with bundle exec rerun. So the catch was that I was using the Gemfile.lock to help with caching / version locking but failed to keep it updated with my Gemfile.
In case anyone is interested there's an alternative.
During image creation, if your dockerfile runs bundle install it will generate a Gemfile.lock in the container. You can use docker run to get the contents, e.g.
docker run web cat Gemfile.lock
You can copy the contents and save a Gemfile.lock to your project directory.
Worked to me:
docker-compose run web bundle install
I am having trouble creating a private gem, pushing it to a private git repo, and then USING that gem in my Gemfile via a :git reference.
The problem is that bundler (while giving no error) doesn't seem to install the gem for me.
I found that I can demonstrate this with any gem, not just mine. So I'm going to demonstrate it using the 'colorize' gem since it is already on github and rubygems, and is a simple gem that has no dependencies. Here is my test.rb file that uses the gem:
require 'colorize'
puts 'some blue text'.colorize(:blue)
CASE ONE (this works):
The Gemfile is as follows:
source 'https://rubygems.org'
gem 'colorize'
Bundle runs happily, and ruby test.rb outputs the blue text just fine.
I then run gem uninstall colorize to clean up before the next test.
CASE TWO (fails):
Now, I change the Gemfile to this:
#source 'https://rubygems.org'
gem 'colorize', :git => 'git#github.com:fazibear/colorize.git'
Note that I commented out the rubygems.org line to be sure I don't accidentally get the gem from rubygems.
Bundle again runs just fine, and can be seen to get the gem from the repo. So far so good. But now, ruby test.rb fails: require cannot load 'colorize'. It would seem that the gem didn't get installed, and indeed if I run gem uninstall colorize to clean up, it says that colorize is not installed!
So what am I doing wrong here, or failing to understand? I want to have the gem installed from a git repo, not rubygems, since the gem is a private gem.
Thanks,
-- Glenn
It seems to me your ssh connection to github is not setup properly.
Try doing a ssh -T git#github.com as suggested here on github, this will give you an error if things are misconfigured. Follow the steps mentioned in the link and then check again, things should work fine then. FWIW, I tried and was able to install the gem in this fashion.
If you were installing this gem on a server, run this command on the server itself.
An alternative to overcome this (the limitation of configuring ssh keys for each account to use git#github.com url in :git) is to instead use a https url (Check out this thread); this however beats all the purpose of using ssh keys.
Of course the gem isn't installed in second case, that is correct, since it was removed. But when bundler clones a git repo, or to use a path key to create a gem, it doesn't use ruby's gem utility, and to know weither the gem is installed successfully you have just to run, and to see the path of the installed gem:
$ bundle show colorize
/home/user/.rvm/gems/ruby-~.~.~#irb/gems/colorize-~.~.~
If case the gem isn't properly installed, you shell see:
Could not find gem 'colorize'.
And will have to issue bundle install again, and trap errors if any.
Since the bundler doesn't call the gem command, doesn't put the checked out gems from git repos or GitHub into common gem pull, and instead of it creates the gem itself inside its pull, and controls it. You should run your script using the bundler itself:
$ bundle exec ./test.rb
or
$ bundle exec ruby test.rb
I just installed Ruby 1.9.3 on Windows 7 and I also installed rubygems. I'm trying to work with rspec so I ran:
gem install rspec
It seemed to work well and everything installed. SO I went on to try the example on this page. But anytime I run the rspec command I get this error message:
"Could not locate Gemfile".
According to the example, I should get: "./bowling_spec.rb:4:
uninitialized constant Bowling"
I've googled it and it was suggested I try bundle exec rspec but it still yielded the same results.
I have also tried the suggestion on this page but it yields the same results. What am I doing wrong? Thanks
Create the Gemfile with this content. Gemfile can have no extension or .gem extension
source 'https://rubygems.org'
gem 'rspec'
so you have
app/
Gemfile or Gemfile.gem
spec/
bowling_spec.rb
Also you might need to execute this commands after
gem install bundler
and then, in the app directory
bundle install
gem install rspec in the same directory as your app and
change require statement to require './bowling.rb'
I installed Aptana, and i want to try Coffeescript. When I try to "Compile and display JS" it won´t work - console shows:
....xyz.sh: line 3: coffee: command not found
....xyz.sh: line 3: pre: command not found
I don´t get it - how do i get it to run?
Thank you!
Edit:
Since yesterday I managed to get compass/sass running in Aptana (yeah!) - so i realized that my question might be wrong: Do i have to tell Aptana (Windows?) where to find the compiler?
Edit 2:
Realized: The problem is - how can this gem be installed (in Aptana if possible):
via https://github.com/netzpirat/guard-coffeescript
I get an error when installing the guard gem:
ERROR: Error installing guard:
The 'ffi' native gem requires installed build tools.
After trying some stuff here is a litte tutorial to setup compass and coffeescript for a project in Aptana:
(Info: I know very little about coding or ruby, so please be patient :) )
Create project ( i choose basic web template)
Terminal:
$ gem install compass
$ compass create myProject --using blueprint
check:
http://compass-style.org/reference/blueprint/
You also have to setup some other stuff:
I found this page and followed it through..
https://github.com/netzpirat/guard-coffeescript
Install bundle:
$ gem install bundle
$ bundle init //to create the gemfile
Install guard:
You need to install Ruby Devkit before - check this links:
http://rubyinstaller.org/downloads/
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
If you did so
$ gem install guard
$ gem install guard-coffeescript
I also installed a JS-Engine as recommended here:
https://github.com/netzpirat/guard-coffeescript#javascript-runtimes
$ gem install therubyrhino
For Coffeescript:
$ gem install coffee-script
$ gem install coffee-script-source
Then you have to edit the gemfile, mine looked like this:
# A sample Gemfile
source "https://rubygems.org"
# gem "rails"
group :development do
gem 'guard'
end
group :development do
gem 'guard-coffeescript'
end
group :development do
gem 'therubyrhino'
end
run bundle
$ bundle
create guardfile
$ guard init
edit the guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'coffeescript', :input => 'myProject/coffeescript', :output => 'myProject/javascript'
you can start the guard with
$ guard start
This worked for me! If you see any mistakes please let me know!
Gemfile:
source "http://rubygems.org"
gem "nokogiri", :git => "git://github.com/tenderlove/nokogiri.git"
When I run bundle, the following error occurs:
Fetching git://github.com/tenderlove/nokogiri.git
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler/source.rb:592:in ``': No such file or directory - git clone "git://github.com/tenderlove/nokogiri.git" "C:/Ruby193/lib/ruby/gems/1.9.1/cache/bundler/git/nokogiri-d4bf05cb9e65f144f074351e5ebe3a0e44c00952" --bare --no-hardlinks (Errno::ENOENT)
How can I solve it?
It's reproducible not only with this gem but also with other gems: cucumber, capybara
I use Windows.
It was because I didn't have Git installed.
I installed Git and added it into PATH system variable. bundle became to work after that
For any other newbies out there, I installed Git on Windows 7 with msysgit.
Then in the msysgit command window (MINGW32) I moved to my rails project directory and ran bundle install and it worked fine.
Thanks for helping me with this Andrey.