Everything is falling apart on my local dev machine and I don't have a clue why. It was running fine last week, after I had formatted my PC to start from scratch. I do my development in WSL and have been doing so for years. No problems until now.
Now, when I tried to commit a simple change to a new branch, husky complains:
08:41:03.286: [nexus] /usr/bin/git -c credential.helper= -c core.quotepath=false -c log.showSignature=false add --ignore-errors -A -f -- resources/js/Pages/Loads/Show.vue resources/js/Pages/Loads/partials/LoadCardPhaseProgress.vue
08:41:03.348: [nexus] /usr/bin/git -c credential.helper= -c core.quotepath=false -c log.showSignature=false commit -F /mnt/c/Users/kerban/AppData/Local/Temp/git-commit-msg-.txt --
time="2024-06-25T08:41:03-04:00" level=warning msg="/home/sturm/dev/xxxxxxx/xxxxx/docker-compose.yml: `version` is obsolete"
time="2024-06-25T08:41:03-04:00" level=warning msg="/home/sturm/dev/xxxxxxx/xxxxx/docker-compose.yml: `version` is obsolete"
> pre-commit
> lint-staged
✖ Current directory is not a git directory!
husky - pre-commit hook exited with code 1 (error)
As a part of my usual troubleshooting steps, I attempt to ensure that all my dependencies are up to date, but both of those fail.
sail npm install:
WARN[0000] /home/sturm/dev/xxxxxxx/xxxxx/docker-compose.yml: `version` is obsolete
WARN[0000] /home/sturm/dev/xxxxxxx/xxxxx/docker-compose.yml: `version` is obsolete
npm error code EACCES
npm error syscall rename
npm error path /tmp/ab542c8e-0317-4b88-b9c3-9039edb3f630/node_modules/electron-to-chromium
npm error dest /tmp/ab542c8e-0317-4b88-b9c3-9039edb3f630/node_modules/.electron-to-chromium-TaB3HUTg
npm error errno -13
npm error Error: EACCES: permission denied, rename '/tmp/***/node_modules/electron-to-chromium' -> '/tmp/***/node_modules/.electron-to-chromium-TaB3HUTg'
npm error at async Object.rename (node:internal/fs/promises:779:10)
npm error at async moveFile (/usr/lib/node_modules/npm/node_modules/@npmcli/fs/lib/move-file.js:30:5)
npm error at async Promise.allSettled (index 0)
npm error at async [reifyPackages] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:325:11)
npm error at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:142:5)
npm error at async Install.exec (/usr/lib/node_modules/npm/lib/commands/install.js:150:5)
npm error at async Npm.exec (/usr/lib/node_modules/npm/lib/npm.js:207:9)
npm error at async module.exports (/usr/lib/node_modules/npm/lib/cli/entry.js:74:5) {
npm error errno: -13,
npm error code: 'EACCES',
npm error syscall: 'rename',
npm error path: '/tmp/ab542c8e-0317-4b88-b9c3-9039edb3f630/node_modules/electron-to-chromium',
npm error dest: '/tmp/ab542c8e-0317-4b88-b9c3-9039edb3f630/node_modules/.electron-to-chromium-TaB3HUTg'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm error A complete log of this run can be found in: /home/sail/.npm/_logs/2024-06-25T12_44_52_487Z-debug-0.log
sail composer install:
WARN[0000] /home/sturm/dev/xxxxxxx/xxxxx/docker-compose.yml: `version` is obsolete
WARN[0000] /home/sturm/dev/xxxxxxx/xxxxx/docker-compose.yml: `version` is obsolete
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
In Filesystem.php line 895:
file_put_contents(/tmp/ab542c8e-0317-4b88-b9c3-9039edb3f630/vendor/composer/installed.php): Failed t
o open stream: Permission denied
install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]
What on earth is going on?
To give some extra context in case it helps, there are two unusual things I do that most people don't when setting up the local clone of the repo.
For one, I have both a personal and work GitHub account, so I have named them as such in my ~/.ssh/config file.
#personal account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
#iel account
Host github.com-iel
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_iel
So when I initially cloned the repo, I had to alter the line slightly.
git clone [email protected]:xxxxxxx/xxxxx.git
However, subsequent git pulls have had no problems, so the remote origin is set up fine.
The second thing is that I have a shell script (which still needs some work, admittedly) to clone the repo and set it up locally. I've tried to make it so that any developer at my company can use it.
# Ensure that Docker is running...
if ! docker info > /dev/null 2>&1; then
echo "Docker is not running."
exit 1
fi
if ! git clone [email protected]:xxxxxxx/xxxxx.git; then
echo "Could not clone the repository. Please check your SSH keys and ensure the 'nexus' directory does not exist."
exit 1
fi
cd xxxxx || exit
if [ ! -f ".env" ]; then
cp .env.example .env
sed -i 's/nexus\.lndo\.site/localhost/g' .env
fi
docker run --rm \
--pull=always \
-v "$(pwd)":/opt \
-w /opt \
-u $(id -u):$(id -g) \
laravelsail/php83-composer:latest \
bash -c "composer install --ignore-platform-reqs"
./vendor/bin/sail build
./vendor/bin/sail up -d
sleep 1
./vendor/bin/sail up -d database
./vendor/bin/sail artisan migrate --seed
./vendor/bin/sail artisan telescope:publish
BOLD='3[1m'
NC='3[0m'
echo ""
if sudo -n true 2>/dev/null; then
sudo chown -R "$USER": .
echo -e "${BOLD}Congratulations! Xxxxx is almost finished installing.${NC} Please finish by following steps 3–6 at https://github.com/xxxxxxx/xxxxx/wiki/Installing-with-Sail#fresh-install"
else
echo -e "${BOLD}Please provide your password so we can make some final adjustments to your application's permissions.${NC}"
echo ""
sudo chown -R "$USER": .
echo ""
echo -e "${BOLD}Congratulations! Nexus is almost finished installing.${NC} Please finish by following steps 3–6 at https://github.com/xxxxxxx/xxxxx/wiki/Installing-with-Sail#fresh-install"
fi
It was originally adapted from Laravel's own installation script from Laravel 10, so I don't know if they've made some breaking changes since then. I recently added the -u $(id -u):$(id -g) \ to the Docker Composer installation command.
Because I have an odd SSH Config setup, I don't use the script as is, I just copy/paste each command and run them separately, modifying the initial git clone, of course.
So, there's my situation. I cannot sail npm i nor sail composer i anymore, nor can I even make a simple commit, because husky thinks it's not a Git repo. I don't know what to do now.