Middleman command not found/ Bundler not working - ruby

I'm trying to install middleman. I installed the gem and can see it in my gem list. However, if I enter middleman -v I get the message middleman: command not found.
I tried installing bundler to run middleman with a Gemfile in the project directory using bundle exec middleman. But when I try to run bundle I get the following error:
bash: /usr/bin/bundle: /usr/bin/ruby: bad interpreter: No such file or directory
I'm running ruby v. 2.6 and installed middleman v.4.3.5 on Ubuntu 18.04.
Any help would be very much appreciated; I've wasted half a day trying to solve this and I'm still on high waters!

which ruby gives me /snap/bin/ruby and my path variable is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/share/rvm/bin. The problem is that ruby is in the snap folder.
I just uninstalled the ruby snap (and snaps in general) and installed "normal" Ruby, which had the correct path (usr/bin/ruby). The middleman installation then worked fine.

Related

why is this sass command giving me an error

I am trying to learn sass so I can develop my front end skills a little bit more because that is what I hope to be some day. The only thing is I can't get sass to work.
Whenever I run the sass --watch . command it returns this error.
>>> Sass is watching for changes. Press Ctrl-C to stop.
write ./test.css
LoadError: no such file to load -- rb-fsevent
Use --trace for backtrace.
I did a bit of research on this error and it was suggested on this site to just simply install the rb-fsevent file that is missing so I ran the gem install rb-fsevent command and then got this error.
Fetching: rb-fsevent-0.9.4.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
so I did a bit of research on THIS error and it was suggested agin on this site to just run the install with sudo. So i did just that I didn't get an error so i was quite excited because I have been fighting with this for a while so i want back to the start of this question and ran the --watch command and got the same exact error. Can anyone help me fix this?
Your first error is because Ruby can't load the rb-fsevent gem. This could be because the gem is not installed. Trying to install the gem was a good idea.
Your second error is because you are trying to install the gem to a directory that you do not have permissions for. Using sudo to do the install is an acceptable solution. You can also do gem install --user-install to install to your home directory.
You are still getting the first error because even though the gem is installed, Ruby cannot load it. This could be because sudo installed the gem with the wrong permissions, or installed it to the wrong location, or Ruby is looking for it in the wrong location.
Thus your solution would be to
Locate the gem files you installed
Check that their permissions allow you to read them
Check ruby -e 'p $LOAD_PATH' to see if Ruby is looking in the right place for the gem

ERROR: While executing gem ... (Zlib::GzipFile::Error) not in gzip format

I am developing a Sencha touch 2 application. I have been following the "Styling the user interface of a Sencha Touch application" tutorial on theming of secha touch applications.
It requires me to install Ruby, Compass and SASS.
I installed Ruby using the installer from rubyinstaller.org.
On executing the following command, I get the expected result which confirms correct installation:
C:\>ruby -v
ruby 1.9.3p327 (2012-11-10) [i386-mingw32]
Current source is up to date:
C:\>gem sources
** CURRENT SOURCES **
http://rubygems.org/
Next, since I am behind a proxy, I used the following command to install HAML/Compass:
C:\>gem install -p [proxy:port] compass
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format**
Can someone help me? I found solutions such as system update, gem sources update, but everything is up to date on my system.
Edit:
C:\>gem install compass
works perfectly fine on my private system. When I try the same command from my workplace I need to use the proxy as mentioned above and that results in an error.
I assume the ERROR occurs since the web sense at my workplace blocks these downloads.
Solution: I downloaded the required gems: chunky_png, fssm, compass, sass, haml etc.. directly from http://rubygems.org/gems and placed these gems in my local directory.
After this I tried gem install compass. This first searches your local directory. On finding the required gems, installation takes place. Does not require connection to the ruby website.
Note: Run the command from the path where the gems are located
eg: I have placed the gems in C:\Ruby193\lib\ruby\gems\1.9.1\gems
So I run the following command :
C:\Ruby193\lib\ruby\gems\1.9.1\gems>gem install compass
I had a similar problem, it worked on my own private laptop, but failed while using a virtual server at work (running Ubuntu 12.10) that used a proxy.
Following the suggestion I found here, from the command line I defined:
export HTTPS_PROXY=proxy-address:proxy-port-number
export HTTP_PROXY=proxy-address:proxy-port-number
and then my gem install package worked fine.

how do I install a ruby plugin in Powershell?

I'd like to install the scheduler_daemon plugin. I get to this part of the instructions and I'm stuck.
script/plugin install git://github.com/ssoroka/scheduler_daemon.git
# Install required gems
gem install daemons rufus-scheduler eventmachine chronic -s http://gemcutter.org
Error:
The term 'script/plugin' is not recognized as the name of a cmdlet, function...
Ok, so I preface it with Ruby:
PS>ruby script/plugin install git://github.com/ssoroka/scheduler_daemon.git
D:\Ruby193\bin\ruby.exe: No such file or directory -- script/plugin (LoadError)
I then tried ruby script/plugin install calendar_helper but got the same error. I tried putting script/plugin in quotes. I tried putting a trailing slash. I tried using http://github.... There are other things I've tried, to no avail.
What do I need to do to install a Ruby plugin via Powershell?
Found it shortly after: rails plugin install git://github.com/ssoroka/scheduler_daemon.git
The thing I've learned about Rails: any info that isn't on an official Rails site may be very outdated. Go to http://guides.rubyonrails.org/ first, second, then stackoverflow, then the rest of the net.
Before Rails 3
ruby script/plugin install git://github.com/ssoroka/scheduler_daemon.git
should work, provided you are at the root of your Rails app.
From Rails 3 onwards, this has become rails plugin install

Jekyll - command not found

I am trying to get Jekyll running but I have no experience with Ruby.
As far as I can tell the installation of Jekyll has succeeded.
However:
$ jekyll
Gives an error:
-bash: jekyll: command not found
This is the gem env result:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Volumes/HDD/DADU/gems
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /Volumes/HDD/DADU/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Volumes/HDD/DADU/gems
- /Volumes/HDD/DADU/.gem/ruby/1.8
- /Library/Ruby/Gems/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
And I found the following paths leading to "something" Jekyll:
~.gem/ruby/1.8/gems/jekyll-0.11.0/lib/jekyll.rb
~.gem/ruby/1.8/gems/bin/jekyll (exec file)
If you are using MacOS, from the Troubleshooting guide:
Jekyll & Mac OS X 10.11Permalink
With the introduction of System Integrity Protection, several directories that were previously writable are now considered system locations and are no longer available. Given these changes, there are a couple of simple ways to get up and running. One option is to change the location where the gem will be installed (again, using sudo only if necessary):
$ gem install -n /usr/local/bin jekyll
For others coming here with the following set up:
OS X + brewed install of ruby + (possibly) zsh
I figured the problem is that after installing jekyll as per their instructions, gem installs the jekyll gem in the brew cellar, not where the OS usually expects it (somehwere in a gem directory for ruby).
So, all that was needed here was to find out where the brew install of ruby installs gems, locate the jekyll binary, and create a symbolic link to it in /usr/bin.
Here is are the steps I took to fix it:
Type gem env and look for GEM PATHS. For me it was:
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1.
Make sure you can see the jekyll binary in the directory from 1 above and copy its path (if you can't, search any other paths listed in GEM PATHS for it). For me it was:
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyll
Use the path from step 2 above to create a symlink to /usr/bin/jekyll. I did it by typing this (you might need sudo to create the symlink):
cd /usr/bin && ln -s /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyll jekyll
Now all should be merry if you type jekyll.
The easiest method of doing this is to use RVM. It manages Ruby and all its gems for you and it's easy to use. See this link for using it.
If you did not want to use that you will need to modify your PATH variables so it can find your gems. I have found this to be tedious and reverted to RVM, but here are the general steps.
You will need to find out where your gems are getting installed. If you did gem install ... the gems will be in ~/.gem/ruby/1.8/gems/bin, if you used sudo gem install ... the gems will be somewhere in /System/Library/Frameworks/Ruby.framework/Versions/1.8/Resources
You have to add this path to your PATH variable. Easiest way to do this is by running :
echo 'PATH=$PATH:above/path/to/gems' >> ~/.bash_profile
If you are using RBENV instead of RVM you simply need to run rehash in the command line after installing jekyll:
rbenv rehash
I installed my ruby2.6.0 and gem via brew on MacOS 10.14.
For me, add the following line to my ~/.zshrc solved this issue.
export PATH=/usr/local/lib/ruby/gems/2.6.0/bin:$PATH
I found jekyll executable file with command locate jekyll.
Maybe a little late, but...
I had some trouble to install Jekyll on Ubuntu and tried everything that people answered in this thread - unfortunately nothing worked.
Then, I watched a video on Jekyll's site and after installing the whole ruby package again, sudo gem install jekyll worked.
Try it before anything else:
sudo apt-get update
sudo apt-get install ruby-full
sudo gem install jekyll
jekyll -v
It seems pretty simple, but it works on Ubuntu.
One solution would be editing your ~/.bashrc file and add this line:
PATH=$PATH:~/.gem/ruby/1.8/gems/bin
This will add ~/.gem/ruby/1.8/gems/bin in Bash's lookup path.
Reopen the terminal and it should work. Or you can use the following command:
. ~/.bashrc
Following steps solved my problem
gem uninstall jekyll
sudo gem install jekyll
Open ~/.bash_profile and add this code in the last line,
export PATH=$PATH:/usr/local/lib/ruby/gems/1.9.1/gems/jekyll-2.5.2/bin
Save and close the .bash_profile
Close and reopen the mac terminal, try running jekyll now, it should work
For me, I followed this installation guide instead of their main page's installation instruction. It worked after I changed the bash_profile file and restarted Terminal.
Jekyll is a ruby gem : Ruby gems in linux, for example, are in /var/lib/gems/1.8, as can be seen in the "ruby env" output.
Thus, you need to add the executables in this directory to your path.
In general, if a ruby gem is "not found" by your OS, it simply indicates that either
1) You don't have the gem installed or
2) You don't have the gem installed in a directory that is on your path.
I have found that there have been a few issues with installing ruby and ruby gems on linux (I have found that it can be tricky on Ubuntu v10, and have confirmed this with the Ruby folks on IRC). Thus, tools like RVM or rbenv might be the best approach to setting up a stable, maintainable ruby environment.
Easier than creating a symlink just install it correctly.
If you got permission errors like a lot of people are getting when trying to use
gem install jekyll
instead use
sudo gem install jekyll
#jayunit100,
I'm running into the same issue with a Jekyll blog. I've installed the gem via RVM in a 'Blog directory and the _config.yml file says that it should generate into Blog/_site. Is it as simple as adding Blog to the PATH or is there something else I'm missing?
Update: My bad, I didn't really have the gem installed. Lesson learned: rvm requirements and brew doctor are there for a reason - before you install stuff USE THEM
In my case I had to run bundle install --force
Then bundle exec jekyll serve works, but jekyll serve still doesn't. It seems I'll have to go with the former from now on…
When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/.gem/ruby/1.9.1. The commands provided by the gems you installed will end up in ~/.gem/ruby/1.9.1/bin. For the programs installed there to be available for you, you need to add ~/.gem/ruby/1.9.1/bin to your PATH environment variable.
For example, if you use bash you can add that directory to your PATH by adding code like this to your ~/.bashrc file:
if which ruby >/dev/null && which gem >/dev/null; then
PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi
https://guides.rubygems.org/faqs/#user-install
I put it in the .bash_profile (Mac OS X).
https://hathaway.cc/2008/06/how-to-edit-your-path-environment-variables-on-mac/
Here's an updated answer for 2020 (soon 2021). To install any Ruby gem, whether it's Jekyll, Bundler, Rails, etc., you need a proper Ruby development environment on a Mac. There are various ways to install Ruby on a Mac, as I have written about in great detail in my definitive guide to installing Ruby gems on a Mac. The only one I recommend is to use a Ruby manager because it's the most flexible and sets you up for success for the long term. My preferred one is chruby because it's the lightest and easiest to use. As part of installing Ruby, you also need to properly configure your shell startup file (typically ~/.zshrc or ~/.bash_profile) so that it knows where to find the gems you install. Otherwise, you'll get the "command not found" error, which I've also written about.
Since there are several steps involved in setting up a working Ruby development environment on a Mac, I wrote some scripts to automate the whole process and make things easier and faster for people. You can read more about the scripts in my guide mentioned above.
I had this problem for a very stupid reason, which is that I was working on Linux and had installed both flatpak and .deb versions of Visual Studio Code. I was confused because I could successfully run bundle exec jekyll serve in the terminal application, but not from the integrated terminal in Visual Studio Code.
Well, it turns out the integrated terminal loaded my PATH correctly in the .deb version but not the flatpak one. So... if you, like me, have foolishly installed multiple versions of Visual Studio Code, check which one you are using.
This is what worked for me. I'm not developing in ruby, and don't have a lot of tools that I use it for, so I don't need RVM. I also don't need to install jekyll as root. I just want it to run.
(This answer is just a more descriptive version of answers by Santa Zhang, jayunit100, and a few others.)
1. Find Local Gem Path
> gem env
Assuming this runs, it will list a bunch of useful information. You are looking for GEM PATHS. If there are two, then you want the one that is found in your home directory. Mine was something like /home/<user>/.local/share/gem/ruby/3.0.0
If it doesn't run, install the ruby gem program and try again.
2. Find Gem Binaries Path
Look in that directory until you find the location where the jekyll executable is actually installed. I found it in /home/<user>/.local/share/gem/ruby/3.0.0/bin/jekyll. But what I need is the directory path, not the file, so: /home/<user>/.local/share/gem/ruby/3.0.0/bin/.
3. Add That to PATH
Figure out how to add a directory to your PATH environment variable. Instructions for that are too extensive to provide here, as it depends on your operating system and preferred shell, and the versions of the same. Search for that information elsewhere on Stackoverflow.
4. Restart Your Session
Close your terminal and open a new one. Make sure the directory was added to your path. Depending on how you set your PATH variable, you might need to log out of your session and log in again.

Error installing gems that use native extensions on Ubuntu, Ruby 1.9.2 via RVM

I get an error while trying to install the ffi gem:
~ - 16:54>gem i ffi
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
rake RUBYARCHDIR=/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/lib RUBYLIBDIR=/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/lib
/home/mdemare/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems.rb:370:in `bin_path': can't find gem rake ([">= 0"]) with executable rake (Gem::GemNotFoundException)
from /home/mdemare/.rvm/gems/ruby-1.9.2-p136/bin/rake:19:in `<main>'
Gem files will remain installed in /home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6 for inspection.
Results logged to /home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/gen/gem_make.out
I'm getting frequent errors of all kinds while installing gems with native extensions, so I assume that there's something broken with my Ubuntu installation, but I've no idea what. I'll post any information you need to diagnose the problem.
EDIT: When I cd to the ffi gem (mentioned in the second but last line), and run the rake line in line 6, I get "Could not find RubyGem rake-compiler".
After gem i rake-compiler, and run rake again, I get this:
configure: error: source directory already configured; run "make distclean" there first
make: *** [/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/build/x86_64-linux/ffi_c/1.9.2/libffi/.libs/libffi_convenience.a] Error 1
rake aborted!
Command failed with status (2): [make...]
Update:
These are my rake gemspecs:
~ - 10:59>find ~/.rvm/ -name 'rake-0.8.7.gemspec'
~/.rvm/gems/ruby-1.9.2-p136/specifications/rake-0.8.7.gemspec
~/.rvm/gems/ruby-1.9.2-p136#global/specifications/rake-0.8.7.gemspec
~/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/specifications/rake-0.8.7.gemspec
The last one is where gem looks, but that gemspec is different from the first one, and doesn't include the executable. Copying the long one doesn't quite solve the problem though - I get a file not found for the rake executable.
This caused me a ton of aggravation at the Boston Hack Day when trying to install Vagrant (for which FFI is a dependency). I ended up wasting so much time that I switched machines to work around the problem.
After the fact, I found a hack that works (although I'm sure there's a better solution). The file that the error message is complaining about
~/.rvm/gems/ruby-1.9.2-p180/bin/rake
differs from other similar copies in that it's missing path setup stuff at the head, so I copied these lines from one of the files that had them:
[genericized per #danv's answer below. Thanks for the improvement!]
ENV['GEM_HOME']=ENV['GEM_HOME'] || '~/.rvm/gems/ruby-1.9.2-p180'
ENV['GEM_PATH']=ENV['GEM_PATH'] || '~/.rvm/gems/ruby-1.9.2-p180:~/.rvm/gems/ruby-1.9.2-p180#global'
ENV['PATH']='~/.rvm/gems/ruby-1.9.2-p180/bin:~/.rvm/gems/ruby-1.9.2-p180#global/bin:~/.rvm/rubies/ruby-1.9.2-p180/bin:' + ENV['PATH']
That fixed it for me. This was a new Ubuntu 10.10 install with no default Ruby installation (which could be part of the problem) and Ruby 1.9.2 installed using RVM. Lots of other gems installed fine, including those requiring native compilation, so the problem is something specific to FFI.
I had a similar problem, and a workaround at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529663 helped me.
In short, try to install the gem with:
$ rake=/usr/bin/rake gem install ffi
#Tom Morris - Tried your method and it worked fine.
I inserted your path specs (modified - see below) into ~/.rvm/gems/ruby-1.9.2-p180/bin/rake after line 12.
I modified the path specs so they are generic using ~ for the user home:
ENV['GEM_HOME']=ENV['GEM_HOME'] || "~/.rvm/gems/ruby-1.9.2-p180"
ENV['GEM_PATH']=ENV['GEM_PATH'] || "~/.rvm/gems/ruby-1.9.2-p180:~/.rvm/gems/ruby-1.9.2-p180#global"
ENV['PATH']="~/.rvm/gems/ruby-1.9.2-p180/bin:~/.rvm/gems/ruby-1.9.2-p180#global/bin:~/.rvm/rubies/ruby-1.9.2-p180/bin:"+ ENV['PATH']
Thanks for finding this fix!
Thanks #Tim Morris and #danv, your answers / comments helped. I adjusted for my setup, which is based more towards a superuser environment. Now this is what /usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake looks like on my server:
require 'rubygems'
version = ">= 0"
ENV['GEM_HOME']=ENV['GEM_HOME'] || "/usr/local/rvm/gems/ruby-1.9.2-p180"
ENV['GEM_PATH']=ENV['GEM_PATH'] || "/usr/local/rvm/gems/ruby-1.9.2-p180:/usr/local/rvm/gems/ruby-1.9.2-p180#global"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'rake', version
load Gem.bin_path('rake', 'rake', version)
The installer attempts to run rake but fails when it isn't found:
can't find gem rake ([">= 0"]) with executable rake (Gem::GemNotFoundException)
You need to install the rake gem: gem install rake.

Resources