Closed jesperronn closed 9 years ago
Yeah, I am facing the same use. Not possible to preview on Atom due to the above mentioned error.
Well, according to the source code, the aglio
is located from PATH
renderApiBlueprintText: (text) ->
fs.writeFileSync '/tmp/atom.apib', text
# Env hack... helps find aglio binary
env =
PATH: process.env.PATH + ':/usr/local/bin'
template = "#{path.dirname __dirname}/templates/api-blueprint-preview.jade"
exec "aglio -i /tmp/atom.apib -t #{template} -o -", {env}, (err, stdout, stderr) =>
if err
@showError(err)
else
console.log stderr
@html @resolveImagePaths stdout
And I think to locate the local aglio
is a relatively tricky solution, here is why:
$(npm bin)
actually locates the bin
folder based on "current location" instead of the file you're editing. And "current location" is usually as same as where binary is located. So to make $(npm bin)
work, it is needed to changed cwd
first..md
file is not passed in. The reason is that, this path isn't always exists, if the file is newly created, and hasn't been saved yet, there is no such "path".So to solve these issues is relatively complicated comparing to its benefits, IMHO.
As a simple workaround, you can either
$(npm bin)
to your PATH
aglio
globally, with npm install -g aglio
To load .bashrc or .bash_profile to set PATH
, I think /bin/bash -lc aglio
is needed instead of /bin/sh -c aglio
https://github.com/sstephenson/rbenv/wiki/Unix-shell-initialization#bash
same here, I am just curious are you guys using nvm?
Any update on this?
No updates on this yet. I suggest installing Aglio globally if you can, otherwise modify your PATH
for the time being to point to the local installation. I'll try and figure out a good way to approach this.
@zdne I'm using nvm and look like there is no solution currently.
Can't we just add aglio
as a dependency to this package and then just use the bundled version?
@LinusU last I had checked, apm
was unable to install the module. This may have changed, however, since protagonist
now uses naan
and support Node.js 0.12. If it works then I'm not against bundling it.
As of the latest release it should try to pick up locally installed Aglio binary. Let me know if you run into any issues with this!
Still doesn't work with nvm :(
Previewing ApiBlueprint Failed
Command failed: /bin/sh -c aglio -i /tmp/atom.apib -t /Users/myusername/.atom/packages/api-blueprint-preview/templates/api-blueprint-preview.jade -o - /bin/sh: aglio: command not found
➜ API Blueprint git:(master) ✗ nvm list
v0.10.33
-> v0.12.2
v0.12.4
system
default -> v0.12.2
➜ API Blueprint git:(master) ✗ npm ls -g --depth=0
/Users/myusername/.nvm/v0.12.2/lib
├── aglio@1.18.0
├── alphashack-libjs@0.0.5 -> /Users/julia/WebstormProjects/metrics-libjs
├── bower@1.4.1
├── bower-update@0.1.0
├── generator-ramlang@0.2.0
├── graphdat-lib@0.0.1 -> /Users/julia/WebstormProjects/metrics-lib
├── grunt-cli@0.1.13
├── gulp@3.9.0
├── karma@0.12.36
├── n_@0.0.7
├── node-gyp@2.0.1
├── npm@2.7.4
├── npm-check-updates@1.5.1
├── osprey@0.2.0-beta.1
├── osprey-cli@0.1.3
├── react-tools@0.13.3
└── yo@1.4.7
Yet I can run algio globally:
➜ API Blueprint git:(master) aglio
Usage: aglio [options] -i infile [-o outfile -s]
Examples:
aglio -i example.md -o output.html Render to HTML
aglio -i example.md -s Start preview server
aglio -t flatly -i example.md -s Custom template
aglio --no-condense -i example.md -s Disable options
Options:
-i, --input Input file
-o, --output Output file
-t, --template Template name or file [default: "default"]
-f, --filter Sanitize input from Windows [default: true]
-c, --condense Condense navigation links [default: true]
-w, --full-width Use full window width [default: false]
-s, --server Start a local live preview server
-h, --host Address to bind local preview server to [default: "127.0.0.1"]
-p, --port Port for local preview server [default: 3000]
-l, --list List templates
Just not through atom. :frowning:
UPDATE: MENTIONING IN CASE NO ONE ELSE WITH NVM UNDERSTOOD THIS:
Fixed by installing aglio in the local project my blueprint files resided in.
Fixed by installing aglio in the local project my blueprint files resided in
Uhm. I guess this is not optimal ...
Fails:
# Open a new shell with `nvm` active in the current environment.
# Install `aglio` globally, and try `control+shift+a` in `atom` to no avail.
$ sudo npm install -g aglio
# Verify it is in an `nvm` directory.
$ npm config get prefix # ~/.nvm/v0.10.37
$ ls ~/.nvm/v0.10.37/bin/ # aglio
Succeeds:
# Open a new shell with `nvm` deactivated in the current environment.
$ nvm deactivate
# Install `aglio` globally, and try `control+shift+a` in `atom` ftw.
$ sudo npm install -g aglio
# Verify it is not in an `nvm` directory.
$ npm config get prefix # /usr/local
$ ls /usr/local/bin/ # aglio
I think this is a reasonable workaround because it only needs nvm
deactivated long enough to install aglio
to the default npm
global, binary directory. nvm
can be reactivated in subsequent shells. Though, this is not a true fix, I suppose.
If you use NVM and installed Atom using the .deb package, try launching atom from the command line, instead of launching it from GUI launcher like Ubuntu's Unity.
If you use Ubuntu and still want to launch Atom from Unity, You can copy:
export NVM_DIR="/home/patrix/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
from .bashrc
to .profile
so you can launch Atom from the launcher (you may need to relogin so Ubuntu can read the changes to .profile
).
I have a project where Aglio is installed locally. Which makes the plugin fail since it looks for Aglio globally. Error on my machine:
Can you change the plugin from
/bin/sh -c aglio
to
$(npm bin)/aglio
Since, I believe this to be more correct. Of course I am aware that this then requires aglio to be installed locally, but isn't this always the case? (package.json to specify)
Or, in your opinion, would it be better with a fallback?