Solved /usr/bin/env: not found during make

Ok, I think I broke my FreeBSD install...

I have been trying to get scripts that call /usr/bin/env to run.
I have tried to create a symlink to the FreeBSD one in /usr/local/bin/env...

After some failed attempts, I left it as it is.

When I now (a while later) try to install other ports using portmaster, I always get the message: /usr/bin/env: not found

I then looked for the /usr/local/bin/env one, but nothing is there.
I am afraid that I broke the env bit of FreeBSD :(

Can anyone help me get this fixed?

Edit
It's even worse, the make command is broken:
sudo make install clean
/usr/bin/env: not found
*** Error code 127


-

FreeBSD version 10.3
 
You won't find one in /usr/local/bin, because it belongs in /usr/bin. You must have managed to delete it somehow. It is not part of a specific package, but of the base operating system. A very standard and very old Unix utility.

It is not a particularly special program: useful little utility to run another program with modified environment variable settings. Also handy as the first hash-bang line in a script: if you know that you have something installed (like python), but you don't know where it is installed, only that it is on the path: you can write a python script that works by putting "/usr/bin/env python" in the first line. Because it is simple and handy, it is used all over - as you have found out the hard way.

You need to get it back. Do you have another FreeBSD 10.3 system handy, and can just copy it over? lf not, find your BSD install image, mount it somewhere, and cd to usr/bin on there and copy it. Sorry, I can't mail one to you; I only have versions 9.0 and 11.1 sitting around here, not 10.3.
 
You won't find one in /usr/local/bin, because it belongs in /usr/bin. You must have managed to delete it somehow. It is not part of a specific package, but of the base operating system. A very standard and very old Unix utility.

It is not a particularly special program: useful little utility to run another program with modified environment variable settings. Also handy as the first hash-bang line in a script: if you know that you have something installed (like python), but you don't know where it is installed, only that it is on the path: you can write a python script that works by putting "/usr/bin/env python" in the first line. Because it is simple and handy, it is used all over - as you have found out the hard way.

You need to get it back. Do you have another FreeBSD 10.3 system handy, and can just copy it over? lf not, find your BSD install image, mount it somewhere, and cd to usr/bin on there and copy it. Sorry, I can't mail one to you; I only have versions 9.0 and 11.1 sitting around here, not 10.3.

YOU, ARE, AWESOME.

Thank you very much for the help!

What I did is download the ISO from download page FreeBSD.
I then mounted the image on my Windows desktop and copied the file /USR/BIN/ENV to a USB device.

I then mounted the USB device and copied the file to /usr/bin/env.
After manually copying the file, the rights are incorrectly set, so I had to fix that first:
$ sudo chmod u+s /usr/bin/env
$ sudo chmod +x /usr/bin/env


This fixed the issue! :D
 
/usr/bin/env is not supposed to have the SUID bit set, chmod 555 /usr/bin/env.

Code:
root@wintermute:~ # ll /usr/bin/env
-r-xr-xr-x  1 root  wheel  12464 Mar 25  2016 /usr/bin/env*
 
/usr/bin/env is not supposed to have the SUID bit set, chmod 555 /usr/bin/env.

Code:
root@wintermute:~ # ll /usr/bin/env
-r-xr-xr-x  1 root  wheel  12464 Mar 25  2016 /usr/bin/env*

A thanks, that will prevent any issues in the future!

Fixed it to match your file:
$ sudo chmod u-ws /usr/bin/env
$ ls -l /usr/bin/env
-r-xr-xr-x 1 root wheel 12464 Aug 10 12:16 /usr/bin/env
 
Erm. Almost. That removes the write access for the owner, it doesn't remove the SUID bit. Just do chmod 555 /usr/bin/env.
 
Erm. Almost. That removes the write access for the owner, it doesn't remove the SUID bit. Just do chmod 555 /usr/bin/env.

You may have missed it, but I also added the `s` to the command:
chmod u-ws

You can set the setuid using chmod u+s command.
Thus removing the setuid bit and the write permission, you can combine chmod u-s and chmod u-w to chmod u-ws?
 
The s was missing the first time you posted it. You added it with a later edit of the post.
 
Back
Top