Comments (4)
You really should debug this within Alfred because it's a different environment from your terminal. One of the main differences being what is available to Alfred on your $PATH
at the time of execution. My initial thought is that nvm
is the problem.
That said, to better determine what's happening within the Alfred environment, add this to the first line of ./lib/scriptfilter.js
:
return console.error(require('./alfred-exec').execSync(`which node; which npm`).toString());
Open Alfred's debugger with the workflow selected and enter the keyword into Alfred. That should tell you:
- which version of node Alfred is using
- the path to
node
Alfred is using - the path to
npm
Alfred is using
Then you can compare that output to the output you get from terminal and nvm
and see where the differences are.
While I currently do not, nor do I have future plans to support nvm
, I understand that not everyone has node
installed at /usr/local/bin/node
so I'm wondering if adding a config variable for path/to/node
at installation time would be beneficial...
from alfred-jira.
I started in Alfred's debugger and moved out because it was easier in the terminal. :)
Your comments sent me down a different path than I was going, and I ended up getting it working. For anyone else running into this issue, first update the first step in the workflow to use the full path to your nvm
-managed node
. Then, apply this patch:
--- a/lib/alfred-exec.js
+++ b/lib/alfred-exec.js
@@ -1,20 +1,21 @@
const child = require('child_process');
let shell = process.env.SHELL;
+let home = process.env.HOME;
let escQuotes = str => str.replace(/"/g,'\\"');
let escSpace = str => str.replace(/ /g, '\\ ');
-const PATH = `eval $(/usr/libexec/path_helper | awk '{print $1}')`;
+const PATH = `/usr/libexec/path_helper | awk '{print $1}'`;
module.exports = {
'exec': (cmd, options, callback) => {
cmd = escQuotes(cmd);
- return child.exec(`${shell} -c "${PATH} ${cmd}"`, options, callback);
+ return child.exec(`${shell} -c ". ${home}/.nvm/nvm.sh && ${PATH} && ${cmd}"`, options, callback);
},
'execSync': (cmd, options) => {
cmd = escQuotes(cmd);
- return child.execSync(`${shell} -c "${PATH} ${cmd}"`, options);
+ return child.execSync(`${shell} -c ". ${home}/.nvm/nvm.sh && ${PATH} && ${cmd}"`, options);
},
'spawn': (cmd, args, options) => {
args = args.map(escSpace)
- return child.spawn(shell, ['-c', `${PATH} ${cmd} ${args.join(' ')}`], options);
+ return child.spawn(shell, ['-c', `. {home}/.nvm/nvm.sh && ${PATH} && ${cmd} ${args.join(' ')}`], options);
}
-}
Et voila!
Thanks for the workflow and help, @steyep. Closing this as you (rightly) don't plan to support nvm
.
from alfred-jira.
Cool, I'm glad you were able to get it working. Don't forget the $
in the spawn
command:
return child.spawn(shell, ['-c', `. ${home}/.nvm/nvm.sh && ${PATH} && ${cmd} ${args.join(' ')}`], options);
You might also consider testing for the nvm
script before trying to load it – that way the workflow won't break if you uninstall nvm
somewhere down the road 😄
const nvm = `test -f ${process.env.HOME}/.nvm/nvm.sh && ${process.env.HOME}/.nvm/nvm.sh`;
module.exports = {
'exec': (cmd, options, callback) => {
cmd = escQuotes(cmd);
return child.exec(`${shell} -c "${nvm}; ${PATH} && ${cmd}"`, options, callback);
},
'execSync': (cmd, options) => {
cmd = escQuotes(cmd);
return child.execSync(`${shell} -c "${nvm}; ${PATH} && ${cmd}"`, options);
},
'spawn': (cmd, args, options) => {
args = args.map(escSpace)
return child.spawn(shell, ['-c', `${nvm}; ${PATH} && ${cmd} ${args.join(' ')}`], options);
}
}
from alfred-jira.
Thanks for spotting the $
!
As to testing for nvm.sh
, I like my hacks as hackish as possible. 8)
Cheers!
from alfred-jira.
Related Issues (20)
- Alfred 4 installation failed HOT 3
- Copy Jira Ticket URL to Clipboard HOT 2
- How to login on standalone JIRA server (not cloud)? HOT 1
- Can't login (401 error) on next-gen Jira cloud HOT 2
- Unable to login HOT 1
- Unable to Login HOT 1
- Projects and Statuses are not being populated.
- Add issue status ("Todo", "In Progress", "Closed", etc.) to issue items in list
- Failed Login: Too Many Attempts HOT 8
- Single sign-on is not supported HOT 3
- URI too long failure after login HOT 1
- {reporter: 'Reporter is required.'} error on creating new Task issue. HOT 1
- Custom keywords + Search + CopytoClipBoard
- Workflow not in the list after installation HOT 1
- Does not work on Apple Silicon M1 due to Electron dependency HOT 1
- Error in login
- Cannot edit description when creating an issue
- Provide information and ability to open newly created ticket from within Alfred workflow
- Setup cannot find Alfred.alfredpreferences if workflows folder does not exist
- Project dead ? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alfred-jira.