Is it possible to run a command in a recipe as if it were run on the live system? If so, how? I want to import my key(s) into gpg before the image is created so I don't have to log onto the system after formatting the SD card.
I found a solution that involves specifying a post install script that runs when do_rootfs is called. All I added to my recipe which installs my public key on the system is below:
pkg_postinst_${PN}() {
#!/bin/sh
if [ -n "$D" ]; then
OPT="--homedir $D/home/root/.gnupg"
else
OPT=""
fi
gpg $OPT --import ${D}${datadir}/mykey.gpg
}
Related
Hi I am new to programming and I hope someone can help with this.
A team mate of mine did some changes yesterday through github and now we get this error when we want to "gcloud app deploy on our gcloud": "ERROR: gcloud crashed (FileNotFoundError): [Errno 2] No such file or directory: '/home/name/project/venv/bin/python3.8'."
The app itself still works but it seems we can not deploy anymore as we get this error. Really appreciate you reading this, thanks.
The error (No such file or directory: '/home/name/project/venv/bin/python3.8') suggests that, a virtualenv (venv) was running (perhaps while gcloud was installed) and it is no longer effective (unable to find /home/name/project/venv/bin/python3.8 in the path).
To reactivate the virtualenv, you can:
source /home/name/project/venv/bin/activate
Which should put python3.8 back in your path:
which python3.8
/home/name/project/venv/bin/python3.8
And should return gcloud to a working state for the current shell session.
When that session ends, you'll need to rerun the source ... command.
It's good practice to explicitly deactivate the virtualenv when you're done with it.
Often, when running, the command shell is prefixed with (venv) to indicate that you're in a virtualenv:
# Create a virtualenv in `xxxx`
python3.8 -m venv xxxx
# Activate `xxxx`
me#host:~ $ source xxxx/bin/activate
# Note my prompt is prefixed with `(xxxx)`
(xxxx) me#host:~ $ which python3.8
/home/me/xxx/bin/python3.8
# Within the virtualenv, `python3.8` is ln'd
(xxxx) me#host:~ $ ls -l $(which python3.8)
/home/me/xxx/bin/python3.8 -> /usr/bin/python3.8
# Deactivate `xxxx`
(xxx) me#host:~ $ deactivate
me#host:~ $ which python3.8
/usr/bin/python3.8
(xxxx) me#host:~ $ deactivate
NOTE In the example above, rather than use the customer venv directory, I'm using xxxx to demonstrate the point.
I am starting a new repo, thinking I should use the most recent Huksy v6 which is installed from LintStaged using their setup guide:
npx mrm lint-staged
// package.json updated with:
"husky": ">=6",
"lint-staged": ">=10",
This adds necessary packages and adds the husky files including the precommit files:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
When i run my commit in the terminal it works fine. However, if I try to run my commit in GitHub Desktop or VSCode (which I know some teammates do), it results in an error for both:
npx: command not found. husky - pre-commit hook exited with code 127 (error)
I have npx installed:
npx -v
// 6.14.10
If I try to install in globall, such as described in other StackOverflow suggestions, it returns a warning about existing location (with & with out sudo):
ERR! EEXIST: file already exists, symlink '../lib/node_modules/npx/index.js' -> '/Users/plucks/.nvm/versions/node/v14.15.4/bin/npx'
npm ERR! File exists: /Users/plucks/.nvm/versions/node/v14.15.4/bin/npx
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
Is there anything I can do so the programs like VSCode & GitHub Desktop can run?
I've got the solution from here. Hope you can find it as well!
https://typicode.github.io/husky/#/?id=command-not-found
https://github.com/typicode/husky/issues/912
Here it is, for clarity:
add a file ~/.huskyrc if you don't have one already
make sure it includes the following:
# ~/.huskyrc
# This loads nvm.sh and sets the correct PATH before running hook
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
As per this suggestion, adding the following to your pre-commit file should fix it:
export NVM_DIR="$HOME/.nvm/nvm.sh"
. "$(dirname $NVM_DIR)/nvm.sh"
export NVM_DIR="$HOME/.nvm"
a=$(nvm ls | grep 'node')
b=${a#*(-> }
v=${b%%[)| ]*}
export PATH="$NVM_DIR/versions/node/$v/bin:$PATH"
So the full file would look like this:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
export NVM_DIR="$HOME/.nvm/nvm.sh"
. "$(dirname $NVM_DIR)/nvm.sh"
export NVM_DIR="$HOME/.nvm"
a=$(nvm ls | grep 'node')
b=${a#*(-> }
v=${b%%[)| ]*}
export PATH="$NVM_DIR/versions/node/$v/bin:$PATH"
npm run test
For husky>=6: update your .husky/pre-commit file to contain this:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npx lint-staged
This will find and expose the current node path and therefore npx path that you are using, which has been configured with Node Version Manager nvm
Before adding any modifications to your project try restarting your IDE as mentioned in this issue
I had to combine the answers of Cathal and Misol.
I did not want to edit the .husky/pre-commit like Cathal for two reasons:
I would need to that for every project I use husky in
It would actually break husky for my fellow developers on Windows
So I added a global ~/.huskyrc file like Misol did with the following contents:
export NVM_DIR="$HOME/.nvm/nvm.sh"
. "$(dirname $NVM_DIR)/nvm.sh"
export NVM_DIR="$HOME/.nvm"
a=$(nvm ls | grep 'node')
b=${a#*(-> }
v=${b%%[)| ]*}
export PATH="$NVM_DIR/versions/node/$v/bin:$PATH"
If you are working on a team with other people who may have installed nvm or node in slightly different fashion than you have, I would not recommend adding any export statements or edits to the $PATH in your .husky/precommit or ~/.huskyrc files.
If you want your VSCode to have proper access to the $PATH you expect from terminal you should always launch VSCode from terminal in the folder you are working from.
For example, in a terminal window:
~/_git/my_project: code .
Will launch VSCode with my_project open in a new window (it should remember your tabs and window state from the last time you worked on your project).
VSCode will now use the $PATH your terminal uses from your ~/.zshrc or ~/.bashrc, etc.
With this setup my .husky/precommit looks like this:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
and my my .lintstagedrc.json looks like this:
{
"*.{js,jsx,ts,tsx}": [
"eslint --fix --debug --max-warnings=-1",
"npm run lint:prettier-fix"
],
"*.{css,less,sass,scss}": ["npm run lint:prettier-fix"],
"*.{g?(raph)ql,json,html,md,y?(a)ml}": ["npm run lint:prettier-fix"]
}
For those using fnm instead of nvm, adding the following to ~/.huskyrc worked for me:
eval "$(fnm env)"
Open VSCode settings and set the Inherit Env setting (Terminal > Integrated: Inherit Env) to false:
"terminal.integrated.inheritEnv": false
This setting enables or disables whether new shells should inherit their environment from VS Code.
I change code as the top answer says. But it doesn't works at first, and then reopen VScode and it works.
In the terminal, I input these commands:
copy this command in terminal and press enter.
vi ~/.huskyrc
copy this command in terminal.
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
input :wq to quit edit state
reopen VScode.
My problem I think is very simple. I would like to have opkg verify signatures before installing packages from my custom opkg repository. The issue I am having is that the keys I added to the opkg-keyrings yocto recipe are all marked as unknown on the target by gpg. They are all installed though. So when i attempt to install a package form my custom repository, It fails because there are no trusted keys. I do not believe that this is a yocto bug, but I am running rocko.
Thank you.
I have gone through the relevant recipes and just don't see anything to change the behavior.
when i attempt to run opkg update i receive the following error.
Collected errors:
opkg_verify_gpg_signature: No sufficently trusted public keys found.
gpg -k result on target(verify fails)
uid [ unknown]
gpg -k result on pc where verify succeeds.
uid
[ultimate]
opkg-key populate
opkg-key adv --list-keys --fingerprint --with-colons |\
sed -E -n -e 's/^fpr:::::::::([0-9A-F]+):$/\1:6/p' |\
opkg-key adv --import-ownertrust
I wanted to add this for anyone who finds the question. I ended up adding a service at start up that runs a script that enables the keys. I have included the key portions of the script above.
I am trying to change the author name of the pushed commits on GitHub. I am following the instructions here step by step: https://help.github.com/articles/changing-author-info/#platform-windows but I am stuck at step 3. I am currently using the command prompt on Windows to do it.
#!/bin/sh
git filter-branch --env-filter $' OLD_EMAIL=“yongjeffrey#hotmail.com" CORRECT_NAME=“Jeffrey Yong" CORRECT_EMAIL=“jeffreyyong10#gmail.com" if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" fi if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] then
export GIT_AUTHOR_NAME="$CORRECT_NAME" export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" fi ' --tag-name-filter cat -- --branches --tags
So I literally copied and pasted the code above in my command prompt and pressed enter but it seems like there's an error. I already have Cygwin installed and I am wondering what is the best way to run the code above.
Create a file named shellpro.sh with the above code in your project directory
Open cygwin
Browse to the project directory using cd command
Type bash shellpro.sh to execute your script
Or you can simply create the file in the project folder and double click it to execute it with git-bash (CygWin in windows)
I realize this is somewhat ancient but I hit this issue. Git for Windows's bash environment on Windows 10 is a custom Cygwin environment (it seems).
I did the following to get some information on how Git sees it's environment when inside filter-branch:
git filter-branch --env-filter "printenv; echo" -- HEAD~..HEAD
This shows all sorts of handy paths like OLDPWD. But I think it's safest to put your script somewhere in your PATH.
So let's say %USERPROFILE%\bin is in your path go and you put your script in %USERPROFILE%\bin\filterscript.sh
#!/bin/bash
OLD_EMAIL="yongjeffrey#hotmail.com"
CORRECT_NAME="Jeffrey Yong"
CORRECT_EMAIL="jeffreyyong10#gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
You can then invoke it like this:
git filter-branch --env-filter "source filterscript.sh" --tag-name-filter cat -- --branches --tags
Note the use of source. The script needs to be sourced otherwise the environment changes will be lost with the child shell executing the script terminates. Sourcing makes the sh instance that will later execute the commit get the environment changes. It's particularly painful if source is omitted because when debugging it seems that the script is indeed executing (and it is) but not in the right shell.
I'm trying to set up a CoffeeScript build system in Sublime Text 3, but I keep getting the following error:
env: node: No such file or directory
[Finished in 0.0s with exit code 127]
[cmd: ['coffee', '-o','/Users/jcourtdemone/Sites/autotempest.com/new_design_sandbox/static/script', '-cw', '/Users/jcourtdemone/Sites/autotempest.com/new_design_sandbox/static/coffee']]
[dir: /Users/jcourtdemone/Sites/autotempest.com/new_design_sandbox/static/coffee]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
My build system looks like this:
{
"name": "Coffee - AT",
"cmd": ["coffee","-o","${project_path:${folder}}/static/script","-cw","${project_path:${folder}}/static/coffee"],
"selector": "source.coffee",
"path":"/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/lib/node_modules/coffee-script/bin"
}
Two things strange about this.
1) It says it's looking in /usr/bin where a symlink to coffee exists.
2) Because of (1), I overrode $PATH to include the actual location of coffee which is /usr/local/lib/node_modules/coffee-script/bin, but for some reason, $PATH isn't being overridden properly, it's sticking with the default $PATH.
Things to note:
i) I've verified that all paths are correct and pass normally through a regular terminal command.
ii) Tried with a "shell": true variable in the build system.
iii) I have another build system for Compass like this that works fine.
Anyone run into similar problems or issues? Any ideas?
In Terminal, type which node, then create a symlink to that location in /usr/bin. For example, if node lives in /usr/local/bin, create the symlink like so:
sudo ln -s /usr/local/bin/node /usr/bin/node
If you look at the source of your coffee script, you'll probably find that the first line is something along the lines of:
#!/usr/bin/env node
Exit code 127 in Sublime means that an env command has failed - so in your case, the build system is finding coffee, but it can't execute it because the node binary isn't in Sublime's default search path.
There are two ways to redefine the default search path for Sublime. The first (and easiest) is to always open it from the command line using the built-in subl command. If you're an OS X power user and don't mind messing with important system settings, check out my post on unix.SE on how to alter the default /usr/bin:/bin:/usr/sbin:/sbin path that you're seeing. Be forewarned that if you don't do things correctly, you may break your system. However, if you're running Mountain Lion (10.8.X) and you follow the instructions exactly, everything should be fine. (I haven't upgraded to Mavericks, so no guarantees on whether it'll work with that version.)
How to solve the problem under an Ubuntu System
The fact is "coffee" command will call /usr/bin/node to continue its work, however, the original "node" command for the node application on an Ubuntu system is changed from "node" to "nodejs" to avoid name conflicting. That is the reason, the shell will compliant you "/usr/bin/env: node: No such file or directory". whenever you type
$ coffee
To solve the bug, just let the shell find something named "node" in its default searching path, and this so-called "node" will promote nodejs. The command "nodejs" lies under path of /usr/bin/nodejs.
We will use symbol link to link "node" with nodejs, and place the link "node" within the default searching path, so that the shell will find it.
sudo ln -s /usr/bin/nodejs /usr/bin/node
But beware, make sure that you do NOT have another "node" command under /usr/bin/, you can check it by try to run
$ which node
I do NOT know what to do if you have installed another "node" application.
In Ubuntu you can install the package nodejs-legacy
sudo apt-get install nodejs-legacy
this package just create a symbolic link to binary nodejs
You should be able to fix this all in your build system without needing to add a symlink on your machine.
For example if node lives in /usr/local/bin/node all you have to do is change the path in your build_system to be:
"path": "/usr/local/bin:$PATH"
I had the same problem with Sublime Text 2.
Creating this sublime build worked for me:
{
"cmd": ["coffee", "-c", "$file"],
"selector" : "source.coffee",
"path" : "/usr/local/lib/node_modules/coffee-script/bin/:/usr/local/bin:$PATH"
}
The following code worked for me in Ubuntu 14.04:
**$ sudo apt-get install NodeJS-legacy**
The other problem was the version checking frameworks such as for e.g: gulp -v the same code also solved this problem.
Type the next in the console:
sudo ln -s /usr/bin/nodejs /usr/bin/node