Make can't find unistd.h although it's present - c

I'm trying to compile http_load inside an alpine docker image.
here is the dockerfile:
FROM alpine:3.5
RUN apk update && apk add wget make gcc linux-headers
WORKDIR /home
RUN wget http://acme.com/software/http_load/http_load-12mar2006.tar.gz && tar xzf http_load-12mar2006.tar.gz
WORKDIR /home/http_load-12mar2006
RUN make
I get this error:
http_load.c:28:20: fatal error: unistd.h: No such file or directory
#include <unistd.h>
^
compilation terminated.
make: *** [Makefile:32: http_load.o] Error 1
I though linux-headers should contain this dependency, and indeed, I can find it here:
/home/http_load-12mar2006 # ls -l /usr/include/linux/unistd.h
-rw-r--r-- 1 root root 157 Oct 25 2016 /usr/include/linux/unistd.h
What is causing this error and how to fix it?

Related

Docker: npm run start causing error, EACCES: permission denied, open '/home/node/node_modules/.cache/.eslintcache

I have created a react app and trying to run it over the docker container with volumes (mapping content inside the container with outside files), everything was working fine earlier but now facing an issue as shared.
Can anyone help me with that? This is a permission issue but doesn't know how to resolve that. root user has access of node_modules folder. How to give access to node user ?
My docker file
FROM node:alpine
USER node
WORKDIR '/home/node'
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "start"]
Commands used:
docker build -t frontend -f Dockerfile.dev .
docker run -p 3000:3000 -v /home/node/node_modules -v $(pwd):/home/node frontend:latest
Error:
Access in container:
~ $ ls -l
total 1488
-rw-rw-r-- 1 node node 124 Jun 20 08:37 Dockerfile.dev
-rw-rw-r-- 1 node node 3369 Jun 17 18:25 README.md
drwxr-xr-x 3 node node 4096 Jun 17 18:45 build
-rw-rw-r-- 1 node node 230 Jun 20 06:56 docker-compose.yml
drwxrwxr-x 1041 root root 36864 Jun 20 19:15 node_modules
-rw-rw-r-- 1 node node 1457680 Jun 18 18:28 package-lock.json
-rw-rw-r-- 1 node node 811 Jun 17 18:26 package.json
drwxrwxr-x 2 node node 4096 Jun 17 18:25 public
drwxrwxr-x 2 node node 4096 Jun 17 18:25 src
It is clear that node_modules folder in container is built by root user during the step npm install, therefore has root as user.
This is the reason we don't have access to that folder when we set up our node user.
To resolve this what we have to do is firstly using the root user we have to give permission to the node user while copying files from local directory to image and then later set up node as the user as shown below:
COPY --chown=node:node package.json .
RUN npm install
COPY --chown=node:node . .
USER node
This file is not a very important file that can cause major application failures if removed. its just a cache file created by external dependencies using eslinter. You can just safely remove by running
sudo rm /home/$USER/path-to-your-project/node_modules/.cache/.eslintcache
Create a .eslintignore file and put * in it.
if you'r running docker-compose, changing the Dockerfile when npm installing worked for me after a lot of investigation
RUN cd /usr/src/app && npm install
Just insert below line in your Dockerfile:
RUN chmod 777 /app/node_modules
before line:
CMD ["npm", "run", "start"]
Rebuild it. Do not need to touch anything else.
This error was haunting me while I was developing a react web app , So here the eslint is asking for few permission that I was not able to find what kind of permission is required so i decided to give all permission available , and that worked for me .
sudo chmod -R 777 /yourProjectDirectoryName
Here the project directory is your directory from home to your current folder.
If this didn't work try going through this, https://idqna.madreview.net/

How do I solve the following git error: No such file or directory [duplicate]

I get this error when I try to commit.
OS - Latest OSX
Git version - git version 2.11.0 (Apple Git-81)
.git/hooks/pre-commit: line 2: ./node_modules/pre-commit/hook: No such file or directory
pre-commit hook runs first when you try to commit changes, it can be used to do certain checks, tests, conditions. In this case, clearly, you don't have it, that's why it's complaining.
Go to .git/hooks directory and remove pre-commit file, as its trying to reference to node_modules/pre-commit/hook. It should resolve it.
Other option is append your commit with option: --no-verify, it will make the commit without checking.
You should delete node_modules folder and install again running npm install or yarn install. After it, you probably solve the problem.
If the script files are actually present, then the cause may be that the first line of the script should be something like:
#!/bin/sh
Otherwise you get the same error.
Any file will work -- e.g., /bin/bash, /usr/local/bin/python3 -- as long as it exists and is executable.
Following #Mutant tip, the simple answer for me was:
rm .git/hooks/pre-commit
Working from macOS, my issue was that Python3 was originally installed via Homebrew, and after I upgraded Python3 via brew update && brew upgrade, I got the same error.
To fix this, I needed to update the symbolic links in the directory that the shebang (#!) line in the .git/hooks/pre-commit file points to.
Here's how I fixed this in my environment:
Look at the contents of the .git/hooks/pre-commit:
cat .git/hooks/pre-commit
The first few lines should look something like:
#!/usr/local/opt/pre-commit/libexec/bin/python3
# File generated by pre-commit: https://pre-commit.com
# ID: 0123456789abcdef0123456789abcdef
import os
import sys
Take note of the path to the python3 executable in the shebang line:
/usr/local/opt/pre-commit/libexec/bin/
cd into that directory.
cd /usr/local/opt/pre-commit/libexec/bin/
Take at look at the Python symlinks:
ls -l | grep python
You'll see some symlinks that are probably broken:
lrwxr-xr-x 1 user group 91 Apr 5 13:33 python -> /usr/local/Cellar/python#3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/bin/python3.9
lrwxr-xr-x 1 user group 91 Apr 5 13:33 python3.9 -> /usr/local/Cellar/python#3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/bin/python3.9
lrwxr-xr-x 1 user group 91 Apr 5 13:33 python3 -> /usr/local/Cellar/python#3.9/3.9.2_4/Frameworks/Python.framework/Versions/3.9/bin/python3.9
Quick note: In case something goes wrong or my answer isn't the solution, you might want to back up these symlinks first by running:
mv python python.bak
mv python3.9 python3.9.bak
mv python3 python3.bak
Update the symbolic links using ln -s [PATH] [LINK], where [PATH] is the location of the Homebrew-updated Python3 executable and [LINK] is python, python3.9, and python3:
ln -s /usr/local/Cellar/python#3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/bin/python3.9 python
ln -s /usr/local/Cellar/python#3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/bin/python3.9 python3.9
ln -s /usr/local/Cellar/python#3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/bin/python3.9 python3
When you've done that, list your Python symlinks again.
ls -l | grep python
You should see the updated symlinks, and git commit should now work.
lrwxr-xr-x 1 user group 89 Apr 6 13:58 python -> /usr/local/Cellar/python#3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/bin/python3.9
lrwxr-xr-x 1 user group 89 Apr 6 13:58 python3 -> /usr/local/Cellar/python#3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/bin/python3.9
lrwxr-xr-x 1 user group 89 Apr 6 13:58 python3.9 -> /usr/local/Cellar/python#3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/bin/python3.9
I got that error after I was played with brew to make yarn work in Webstorm.
The fix is just re-install pre-commit again.
brew install pre-commit
https://pre-commit.com/
For anyone who is having this problem with husky, for me what solved it is running:
husky install
(which I forgot to run) The docs talk about it under usage, aka npm run prepare for one time after you set up husky. usage
Nothing helps me but remove local repo and clone it again. This kinda error appears when I accidentically tried commit and push changes to master..
If you look at your package.json you will get a better idea about the problem.
Husky is npm dependency so basically you got the error because for some reason it's not available.
So, option one run
npm i
Or if you already did that
rm -rf node_modules
npm i
I had installed pre-commit using homebrew, and installed the pre-commit-vscode extension and got this error.
What solved this was to also run pre-commit install from the root of the git repo.
In my case in Mac OS, upgrading python3 via brew somehow messed up python3 location whereas the shebang in pre-commit was was still pointing to the old python3 location. So finding new python3 location via which python3 and updating same in pre-commit and other scripts under .githooks folder did fixed the issue.
INGW64 ~/code/ingestor-gdelt (test-build)
$ git commit -m "your comment"
.git/hooks/pre-commit: line 9: py: command not found
.git/hooks/pre-commit: line 10: py: command not found
git commit --no-verify -m "your comment"
This command resolved my issue !!
just make sure you have hooks folder inside of .git . if not make one.
Deleting pre-commit from hooks inside .git worked for me

mongod : Failed to unlink socket file

I am trying to start mongod.
I run
sudo service mongod start
but I get:
Failed to unlink socket file /tmp/mongodb-27017.sock Unknown error
Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp
685
Theres a question here but I have tried all solutions to no avail
Os: Ubuntu 16.04
When I run
ls -lsah /tmp/mongodb-27017.sock
I see:
0 srwx------ 1 mongodb mongodb 0 Jun 14 11:45 /tmp/mongodb-27017.sock
Then I run
rm /tmp/mongodb-27017.sock
sudo service mongod start
When I run
ls -lsah /tmp/mongodb-27017.sock
again, I see:
0 srwx------ 1 mongodb mongodb 0 Jun 14 11:45 /tmp/mongodb-27017.sock
When I run mongod, it gives me the same error.
I had the same problem and noticed this old answer: https://stackoverflow.com/a/34290982/2683681.
You can use their command:
sudo chown `whoami` /tmp/mongodb-27017.sock
But if you're using root then you'd better be doing:
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
My problem stemmed from the fact that root owned the socket.

Error while extracting libunwind-headers on OS X Mavericks

I'm having a difficult time upgrading the libunwind-headers port in macports. I've already looked into the previous post on this:
sudo xcodebuild -license agree
This did not fix the problem.
Here's my terminal output:
new-host-2 [~] % sudo port upgrade outdated
---> Extracting libunwind-headers
Error: org.macports.extract for port libunwind-headers returned: command execution failed
Please see the log file for port libunwind-headers for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_libunwind-headers/libunwind-headers/main.log
Error: Problem while installing libunwind-headers
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Here's my log file:
version:1
:debug:main libunwind-headers has no conflicts
:debug:main Executing org.macports.main (libunwind-headers)
:debug:main changing euid/egid - current euid: 0 - current egid: 0
:debug:main egid changed to: 501
:debug:main euid changed to: 502
:debug:main Skipping completed org.macports.archivefetch (libunwind-headers)
:debug:main Privilege de-escalation not attempted as not running as root.
:debug:main Skipping completed org.macports.fetch (libunwind-headers)
:debug:main Privilege de-escalation not attempted as not running as root.
:debug:main Skipping completed org.macports.checksum (libunwind-headers)
:debug:main Privilege de-escalation not attempted as not running as root.
:debug:extract extract phase started at Wed Nov 6 12:42:26 EST 2013
:notice:extract ---> Extracting libunwind-headers
:debug:extract Executing org.macports.extract (libunwind-headers)
:info:extract ---> Extracting libunwind-35.1.tar.gz
:debug:extract setting option extract.args to '/opt/local/var/macports/distfiles/libunwind-headers/libunwind-35.1.tar.gz'
:debug:extract Environment: CPATH='/opt/local/include' CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.mac ports.org_release_ports_devel_libunwind-headers/libunwind-headers/work/.CC_PRINT_OPTIONS' LIBRARY_PATH='/opt/local/lib' CC_PRINT_OPTIONS='YES' MACOSX_DEPLOYMENT_TARGET='10.9'
:debug:extract Assembled command: 'cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_libunwind-headers/libunwind-headers/work" && /usr/bin/gzip -dc '/opt/local/var/macports/distfiles/libunwind-headers/libunwind-35.1.tar.gz' | /usr/bin/gnutar --no-same-owner -xf -'
:debug:extract Executing command line: cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_libunwind-headers/libunwind-headers/work" && /usr/bin/gzip -dc '/opt/local/var/macports/distfiles/libunwind-headers/libunwind-35.1.tar.gz' | /usr/bin/gnutar --no-same-owner -xf -
:info:extract sh: /usr/bin/gnutar: No such file or directory
:info:extract gzip: error writing to output: Broken pipe
:info:extract gzip: /opt/local/var/macports/distfiles/libunwind-headers/libunwind-35.1.tar.gz: uncompress failed
:info:extract Command failed: cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_libunwind-headers/libunwind-headers/work" && /usr/bin/gzip -dc '/opt/local/var/macports/distfiles/libunwind-headers/libunwind-35.1.tar.gz' | /usr/bin/gnutar --no-same-owner -xf -
:info:extract Exit code: 127
:error:extract org.macports.extract for port libunwind-headers returned: command execution failed
:debug:extract Error code: NONE
:debug:extract Backtrace: command execution failed
while executing
"$procedure $targetname"
:info:extract Warning: targets not executed for libunwind-headers: org.macports.activate org.macports.extract org.macports.patch org.macports.configure org.macports.build org.macports.destroot org.macports.install
:notice:extract Please see the log file for port libunwind-headers for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_libunwind-headers/libunwind-headers/main.log
Does this seem like a bug, or am I doing something incorrectly? I've also tried cleaning it, and uninstalling/re-installing it.
Selfupdating also did not return any errors.
sudo port -v selfupdate
I know it's waaaaay late on this, but for anybody getting here like I did:
sudo ln -s /usr/bin/tar /usr/bin/gnutar
Mavericks apparently changed the file name of tar.

How to get rid off - sudo: /usr/lib/sudo/sudoers.so must be only be writable by owner sudo: fatal error, unable to load plugins

I am trying to configure apache2 with cgi (python). For that, I have to change permissions of some folders and files but I am getting sudo fatal errors every time I try to change permission of a file or a Folder.
For Example:
1
j#ubuntu:/etc/apache2$ ls
apache2.conf envvars magic mods-enabled sites-available
conf.d httpd.conf mods-available ports.conf sites-enabled
j#ubuntu:/etc/apache2$ sudo chmod 777 httpd.conf
sudo: /usr/lib/sudo/sudoers.so must be only be writable by owner
sudo: fatal error, unable to load plugins
...................................................................................
2
j#ubuntu:/usr/lib/cgi-bin$ sudo /etc/init.d/apache2 restart
sudo: /usr/lib/sudo/sudoers.so must be only be writable by owner
sudo: fatal error, unable to load plugins
...................................................................................
3
j#ubuntu:/usr/lib$ sudo chmod -R 777 /usr/lib/cgi-bin
sudo: /usr/lib/sudo/sudoers.so must be only be writable by owner
sudo: fatal error, unable to load plugins
...................................................................................
Note:
j#ubuntu:/etc/apache2$ ls -l /usr/lib/sudo/sudoers.so
-rwxrwxrwx 1 root root 177452 Jan 31 2012 /usr/lib/sudo/sudoers.so
Any help would be highly appreciated !
If you have docker installed on your host, you can leverage its permission vulnerabilities on volumes to solve this issue.
Run
docker run -it -v /usr/lib/sudo:/tmp ubuntu:xenial
Once inside the container, being the root user there, you can:
cd /tmp
chown root sudoers.so or chmod 644 sudoers.so depending on the exact issue
It's not a really clean solution but it solves the issue.
You have to login to root shell to resolve this sudoers.so permission issue. If you have root account login, directly login to root shell otherwise search something like "How do I boot into a root shell" or "Drop to root shell prompt". If you use Ubuntu you can follow this link https://askubuntu.com/questions/92556/how-do-i-boot-into-a-root-shell.
Once you are in root shell change the permission of the file /usr/lib/sudo/sudoers.so to
#chmod 644 /usr/lib/sudo/sudoers.so
for OSX, there is diskutil command to repair disk permissions:
diskutil resetUserPermissions / `id -u`
it will take a while :( ... you might first try to open script editor, create new script and execute:
do shell script "chown -R root /usr/local/libexec/sudo/sudoers.so" with administrator privileges
if that does not work, the repairpermission should do the trick.
Please try to login as a root user and change the file permission for the directory as
chmod 700 /usr/lib/sudo/sudoers.so then it will solve your problem.
It worked for me!
Try this:
pkexec chmod go-w /usr/lib/sudo/sudoers.so

Resources