Straight.el: Installation of prettier.el seems faulty

Created on 25 Oct 2020  ยท  13Comments  ยท  Source: raxod502/straight.el

Hi, I'm new to straight.el so I hope this is the right place to bring this upโ€ฆ

What's wrong

Installing prettier.el works:

(straight-use-package 'prettier)

But when I try to enable prettier by using M-x prettier-mode RET I get the following error:

insert-file-contents-literally: Opening input file: No such file or directory, /home/aleks/.emacs.d/straight/build/prettier/prettier-el.js.gz.base64

I'm currently migrating my installation from package.el & use-package to straight.el & use-package, so I know that in the former setup, prettier worked.

Directions to reproduce

Add to basic snippet:

(straight-use-package 'prettier)

Then M-x prettier-mode in any buffer.

Version information

  • Emacs version: GNU Emacs 27.1.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20) of 2020-09-21
  • Operating system: Ubuntu 20.4

Additional Information:

This is what the directory looks like:

.emacs.d/straight/build/prettier/
โ”œโ”€โ”€ bootstrap.js -> /home/aleks/.emacs.d/straight/repos/prettier.el/bootstrap.js
โ”œโ”€โ”€ externs.js -> /home/aleks/.emacs.d/straight/repos/prettier.el/externs.js
โ”œโ”€โ”€ prettier-autoloads.el
โ”œโ”€โ”€ prettier.el -> /home/aleks/.emacs.d/straight/repos/prettier.el/prettier.el
โ”œโ”€โ”€ prettier.elc
โ””โ”€โ”€ prettier-el.js -> /home/aleks/.emacs.d/straight/repos/prettier.el/prettier-el.js
branch bug compatibility melpa recipe handling

Most helpful comment

Whoopsies. You've successfully found one of only 13 recipes in all of MELPA that use the :branch property, which was not handled correctly by straight.el until https://github.com/raxod502/straight.el/pull/609 was merged recently (thanks @isker!). I've backported that fix from develop to master, so if you update straight.el then you should be good to go and prettier should work out of the box.

All 13 comments

Ah, I dug around a bit, and it seems that the following will help:

cd straight/repos/prettier.el/
npm install --frozen-lockfile
make

Then copy over the files:

cd ../../build/prettier
cp ../../repos/prettier.el/dist/prettier-el.js.gz.base64 .
cp ../../repos/prettier.el/dist/bootstrap-min.js .

Then everything works as exected. I guess it's a problem with prettier not providing a way to install using straight then? Is there a way to automate these steps with straight?

Feel free to close this, as I'm not sure anymore that this is a bug with straight.el

Perfect timing! We've just added support for running build commands on the develop branch.
You should be able to add to the build steps to prettier's recipe (the rest of the defaults will be inherited).
For example, using the steps you've provided:

(use-package prettier
  :straight (:build (("npm" "install" "--frozen-lockfile")
                     ("make")))
  ;;etc
  )

The default recipe for prettier can be obtained by running M-x straight-get-recipe prettier.
On my system it returns:

(prettier :type git :flavor melpa
          :files (:defaults "*.js" "*.base64" "prettier-pkg.el")
          :branch "release"
          :host github
          :repo "jscheid/prettier.el")

Note the :files keyword should already copy over the js, base64 and prettier-pkg.el files to straight/build/prettier. They copying takes place after the :build step, too- so any files generated by those commands can be considered. If you need to extend that you can override it in the recipe as well.

(use-package prettier
  :straight ( :build (("npm" "install" "--frozen-lockfile") ("make"))
              :files (:defaults "*.js" "*.base64" "prettier-pkg.el" "example-file"))
  ;;etc
  )

Check out the docs on the recipe format for more info about :build and :files:

https://github.com/raxod502/straight.el/tree/develop#the-recipe-format

Happy to help if you have any questions or run into any problems.

~ Nick

I don't know, that sounds like a bug in straight.el. All the MELPA recipes should work out of the box, after all package.el does not work with build steps either. I'll check on it. Of course, what @progfolio suggested should also get things working, until we figure out what is going on that causes this package to work in package.el but not straight.el.

@raxod502 I think that this prettier.el issue might help shed some light on the situation. Unfortunately, I know virtually nothing about how packages are built/distributed in Emacs.

@progfolio Thanks for the instructions. I actually wanted to stay on the main branch for now, as I just tried straight.el out for the first time. Unfortunately, the make step has quite some dependencies that it requires on the building system (including a compiler, pandoc and python-panflute) so it'd be nice if we could avoid having to use make at all. Maybe @jscheid could help?

@adimit Thanks for the extra info. I have a hunch, but I'm not able to get to my computer right now. What does M-x straight-get-recipe prettier return for you?

I suspect this is related to #609 as prettier specifies a "release" branch in its MELPA recipe:

https://github.com/melpa/melpa/blob/master/recipes/prettier

Haven't been able to test this yet myself, but the following may work:

(straight-use-package '(prettier :branch "release"))

@progfolio Here's the output of straight-get-recipe:

(prettier :type git :flavor melpa :files (:defaults "*.js" "*.base64" "prettier-pkg.el") :host github :repo "jscheid/prettier.el")

Using the release branch as you indicated does not copy the necessary files to the straight/build/prettier folder :frowning_face:.

Let me know if you need anything specific from me, but sounds like you're on the right track. You definitely want the release branch, the master branch doesn't have all the files required.

I wouldn't try running the build, you're much better off just grabbing the pre-built files off the release branch.

Whoopsies. You've successfully found one of only 13 recipes in all of MELPA that use the :branch property, which was not handled correctly by straight.el until https://github.com/raxod502/straight.el/pull/609 was merged recently (thanks @isker!). I've backported that fix from develop to master, so if you update straight.el then you should be good to go and prettier should work out of the box.

It appears like it's building cleanly now for me.
build/prettier has the following files:

โ”œโ”€โ”€ bootstrap-min.js -> /tmp/prettier-branch-test.straight/straight/repos/prettier.el/bootstrap-min.js
โ”œโ”€โ”€ dir -> /tmp/prettier-branch-test.straight/straight/repos/prettier.el/dir
โ”œโ”€โ”€ prettier-autoloads.el
โ”œโ”€โ”€ prettier.el -> /tmp/prettier-branch-test.straight/straight/repos/prettier.el/prettier.el
โ”œโ”€โ”€ prettier.elc
โ”œโ”€โ”€ prettier-el.js.gz.base64 -> /tmp/prettier-branch-test.straight/straight/repos/prettier.el/prettier-el.js.gz.base64
โ””โ”€โ”€ prettier.info -> /tmp/prettier-branch-test.straight/straight/repos/prettier.el/prettier.info

Test Case

(straight-bug-report
  :user-dir "prettier-branch-test.straight"
  :preserve t
  :pre-bootstrap 
  (setq straight-repository-branch "master")
  :post-bootstrap 
  (straight-use-package 'prettier)
  (prettier-mode))

  • Test run at: 2020-10-26 12:10:36
  • system-type: gnu/linux
  • straight-version: prerelease (HEAD -> feat/el-get-recipe-support, fork/feat/el-get-recipe-support) 797314a 2020-10-26
  • emacs-version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.3, Xaw3d scroll bars) of 2020-10-14

Output

Prettier syncing config


Yes, it works for me now with a clean Emacs installation. Thanks a lot for your quick responses!

I think I had to remove the build cache in order to enable the new behaviour in my running Emacs installation. It works now :smiley:

Hmm, it's always a bit unfortunate when you have to remove the build cache. That "should" never happen; feel free to open a bug if you observe a situation where you always have to do something manual in order to get things to update.

OK, I'll see if I can reproduce the behaviour and open an issue if I can.

I did run into the very same problem with straight and prettier. Happy that just updating straight solved it.

Regarding the build cache, since I had it also installed before, what needs to be removed is the prettier folder in the repos folder, otherwise it will always build it from this (which is/was based on the wrong branch if installed before straight had that fix). Maybe that's why it didn't work for @adimit in a 'non-clean' emacs installation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

progfolio picture progfolio  ยท  3Comments

parsoj picture parsoj  ยท  4Comments

Fuco1 picture Fuco1  ยท  3Comments

mclearc picture mclearc  ยท  4Comments

aspiers picture aspiers  ยท  4Comments