How to fix ruby error: sh: 1: make: not found

老子叫甜甜 提交于 2019-12-12 18:44:18

问题


I am working my way through a video tutorial at http://gettingstartedwithdjango.com/en/lessons/introduction-and-launch/

I am working on win7 and using git-bash for my terminal. I have installed the latest virtualbox - 4.2.12 and the latest vagrant - 1.22.

I tried to run vagrant up and got:

  $ vagrant up
  Bringing machine 'default' up with 'virtualbox' provider...
  [default] Setting the name of the VM...
  [default] Clearing any previously set forwarded ports...
  [default] Creating shared folders metadata...
  [default] Clearing any previously set network interfaces...
  [default] Preparing network interfaces based on configuration...
  [default] Forwarding ports...
  [default] -- 22 => 2222 (adapter 1)
  [default] -- 8000 => 8888 (adapter 1)
  [default] Booting VM...
  [default] Waiting for VM to boot. This can take a few minutes.
  [default] VM booted and ready for use!
  [default] Configuring and enabling network interfaces...
  [default] Mounting shared folders...
  [default] -- /vagrant
  [default] -- /tmp/vagrant-chef-1/chef-solo-1/cookbooks
  [default] -- /tmp/vagrant-chef-1/chef-solo-2/cookbooks
  [default] Running provisioner: shell...
  [default] Running: inline script
  stdin: is not a tty
  ERROR:  Error installing chef:
          ERROR: Failed to build gem native extension.      

          /usr/bin/ruby1.8 extconf.rb
  creating Makefile      

  make
  sh: 1: make: not found    


  Gem files will remain installed in /var/lib/gems/1.8/gems/yajl-ruby-1.1.0 for in
  spection.
  Results logged to /var/lib/gems/1.8/gems/yajl-ruby-1.1.0/ext/yajl/gem_make.out
  Building native extensions.  This could take a while...
  The following SSH command responded with a non-zero exit status.
  Vagrant assumes that this means the command failed!      

      chmod +x /tmp/vagrant-shell && /tmp/vagrant-shell

When I do:

$ which make

I get:

/c/opscode/chef/embedded/bin/make

so it looks like make is in filepath

How can I fix this?

addendum: when I edit the vagrantfile to:

config.vm.provision :shell, :inline => "curl -L https://opscode.com/chef/install.sh | bash"

I get:

/tmp/vagrant-shell: line 1: curl: command not found

回答1:


The basebox you're using does not have the "build-essential" package installed by default, and it has a "shell provisioner" that installs the Chef gem into the default Ruby environment. Chef has a dependency on the JSON RubyGem, which itself has C extensions that must be compiled. This is what is looking for make.

To resolve this issue, I'd recommend using Opscode's "omnibus" full stack installer for Chef. This can be used by changing the shell provisioner line to:

config.vm.provision :shell, :inline => "curl -L https://opscode.com/chef/install.sh | bash"

Or, if your basebox doesn't have curl, use wget:

config.vm.provision :shell, :inline => "wget -O https://opscode.com/chef/install.sh | bash"

The [install.sh][3] script simply inspects the VM to determine what its platform is so it can retrieve the proper URL from an S3 bucket. If you prefer you can use the constructed URL to download the .deb file directly:

https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/11.04/x86_64/chef_11.4.4-2.ubuntu.11.04_amd64.deb

And then install it:

dpkg -i chef_11.4.4-2.ubuntu.11.04_amd64.deb

See the Vagrant documentation on shell provisioners to see how to write this as a small script.




回答2:


In which machine, did you run which make? (host/guest). Make sure guest(virtualbox) have a make.

https://github.com/scottmuc/vagrant-postgresql/issues/1#issuecomment-7798110




回答3:


If the OS doesn't have make pre-installed, and you still want to continue moving forward, you can do something along the lines of:

e = package "make" do
        action :nothing
end

e.run_action(:install)

which will install the make package at compile time, before any of your cookbooks try to use it. You should put this in one of your recipes, preferably at the top, so it is clear to other readers what is happening.




回答4:


It tured out, Thanks I had the wrong version of chef. I needed version 11.4.2 which is not the most recent. The most recent did not work for me . I went to

http://www.opscode.com/chef/install/

and downloaded and installed:

chef-client-11.4.2-1.windows.msi

and it worked after doing vagrant destroy, and following that with vagrant up.



来源:https://stackoverflow.com/questions/17119003/how-to-fix-ruby-error-sh-1-make-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!