rajasegar / alacritty-themes

:rainbow: :lollipop: Themes :candy: :heart_eyes: for Alacritty: A cross-platform GPU-accelerated Terminal emulator
MIT License
703 stars 70 forks source link

v4.1.2 is taking current directory as root directory #44

Closed z00rat closed 3 years ago

z00rat commented 3 years ago

Hi, I am the package manager of this in AUR. When i tried to update it i got in to this problem.

Describe the bug This program takes current directory as the root directory of the package. In the new update rootDirectory() function takes process.env.PWD as the root directory which causes error like this...

❯ alacritty-themes
? Select a theme ›
❯   3024.dark
    3024.light
    Afterglow
    Argonaut
    Ashes.dark
    Ashes.light
    Astromouse
    Atelierdune.dark
    Atelierdune.light
  ↓ Atelierforest.darknode:fs:585
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, open '/home/USER/themes/3024.dark.yml'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at updateThemeWithFile (/usr/lib/node_modules/alacritty-themes/index.js:51:24)
    at updateTheme (/usr/lib/node_modules/alacritty-themes/index.js:100:10)
    at /usr/lib/node_modules/alacritty-themes/index.js:107:12 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/USER/themes/3024.dark.yml'
}

problematic line

To Reproduce Steps to reproduce the behavior:

  1. install v4.1.2
  2. run alacritty-themes in terminal
  3. See error

Expected behavior taking root directory as root directory. For linux where its installed as root is "/usr/lib/node_modules/alacritty-themes".

Desktop (please complete the following information):

Additional context I will try to patch it by hard coding the location for now and update the package.

z00rat commented 3 years ago

This was enough to fix the problem in my package.

--- index.original.js   2021-09-22 11:53:04.435471903 +0600
+++ pkg/alacritty-themes/usr/lib/node_modules/alacritty-themes/src/helpers/index.js 2021-09-22 11:53:33.317118492 +0600
@@ -7,7 +7,7 @@
 );

 function rootDirectory() {
-  return process.env.PWD;
+  return "/usr/lib/node_modules/alacritty-themes";
 }

 function themeFilePath(themeName) {
JuanVqz commented 3 years ago

Hi @z00rat, thank you for opening this issue, sorry for the issue.

I thought the rootDirectorymethod is returning the root alacritty-themes folder package but it seems like it's returning this one pkg/alacritty-themes/usr/lib/node_modules/alacritty-themes/src/helpers/index.js, right?

since you are using the AUR package manager, it means you didn't use npx alacritty-themes either npm i -g alacritty-themes, right?

how can I install the AUR package manager and use it in arch? I'll try to reproduce the error in a docker container if you have baby steps it would be great, please! (I haven't used arch at all)

JuanVqz commented 3 years ago

being on ubuntu, I just printed out the PWD in the bin/cli.js file and it returns the alacritty-themes directory

2021-09-22_08-08

z00rat commented 3 years ago

I thought the rootDirectorymethod is returning the root alacritty-themes folder package but it seems like it's returning this one pkg/alacritty-themes/usr/lib/node_modules/alacritty-themes/src/helpers/index.js, right?

No. that location is in my build environment. what i wish to get is /usr/lib/node_modules/alacritty-themes. But i'm getting current directory. Like if I run from ~/docs/whatever/testing i'm getting /home/USER/docs/whatever/testing

since you are using the AUR package manager, it means you didn't use npx alacritty-themes either npm i -g alacritty-themes, right?

sorry for not telling you that but npm i -g alacritty-themes is broken. and the way we package this app is just like what npm do. and now i tried npx alacritty-themes one too. it still broken. btw, im using node v16.9.1

how can I install the AUR package manager and use it in arch? I'll try to reproduce the error in a docker container if you have baby steps it would be great, please! (I haven't used arch at all)

I think this is enough: https://dev.to/cloudx/testing-our-package-build-in-the-docker-world-34p0 you will need a AUR helper to install from AUR. I recommend paru. my package like is https://aur.archlinux.org/packages/alacritty-themes/

(I haven't used arch at all)

the pain and fun about using archlinux is you have to read a lot of docs....

JuanVqz commented 3 years ago

I'd like to change to archlinux one day. what distro do you recommend?

I just tried and yes, I noticed the npx alacritty-theme is broken, so, I'm able to reproduce the error, I'll take a look as soon as possible.

z00rat commented 3 years ago

being on ubuntu, I just printed out the PWD in the bin/cli.js file and it returns the alacritty-themes directory

nop something is wrong... 21-Sep-22--21-45-52-byFlameshot

and if ya need it..... 21-Sep-22--22-38-33-byFlameshot

btw you are using ./bin/cli.js but when i say alacritty-themes it means

❯ where alacritty-themes
/usr/bin/alacritty-themes
❯ file /usr/bin/alacritty-themes
/usr/bin/alacritty-themes: symbolic link to ../lib/node_modules/alacritty-themes/bin/cli.js
JuanVqz commented 3 years ago

taking advantage of you are online, I'll do a quick change in order to see if it solves the problem, oh! but I cannot release versions, would you use the commit's SHA in order to just test?

z00rat commented 3 years ago

I'd like to change to archlinux one day. what distro do you recommend?

TBH here, I use arch because it gives me nothing at first and i have to do almost everything by myself. which is the best for making a system like your dream. Drawback, it takes a loooooooooot of time. play around in vm then move. thats what i like to do.

I just tried and yes, I noticed the npx alacritty-theme is broken, so, I'm able to reproduce the error, I'll take a look as soon as possible.

yay so im not wrong.

z00rat commented 3 years ago

taking advantage of you are online, I'll do a quick change in order to see if it solves the problem, oh! but I cannot release versions, would you use the commit's SHA in order to just test?

it will be better if you can give me a file like https://registry.npmjs.org/alacritty-themes/-/alacritty-themes-4.1.2.tgz no clue how to build one like this.

in my package i download this from npm and tell npm to install it a folder as if its root directory. this is what i followed https://wiki.archlinux.org/title/Node.js_package_guidelines its just a wrapper around npm .....

z00rat commented 3 years ago

I created this pull request after finding a potential solution. so, the variable __dirname gives me the actual location of the file. not even the symlinked one. and from there two step upstairs is the root which we are trying to calculate.

please check if it works on other OS too.

EdRW commented 3 years ago

I created this pull request after finding a potential solution. so, the variable __dirname gives me the actual location of the file. not even the symlinked one. and from there two step upstairs is the root which we are trying to calculate.

please check if it works on other OS too.

Thanks a bunch. Your solution worked for me.

I was facing the same issue when I installed alacritty-themes using npm (installed via nvm) on Pop!_OS.

In my case, the installation directory was ~/.nvm/versions/node/v14.17.6/lib/node_modules/alacritty-themes but alacritty-themes was looking in my current working director to find the themes directory.

z00rat commented 3 years ago

updated my package this morning and no one complained .... looks good bro.

its was fun working on this bug. learned a lot.

JuanVqz commented 3 years ago

Cool!! you are always welcome to contribute here! BTW, I read more about rolling release operative systems and I just switched to manjaro, I had some problems installing RVM (ruby version manager) because I used to develop on ruby and rails but at the end I was able to solved (reading the Arch Wiki). so far Manjaro is super cool all it's easy with the pamac tool.

You inspired me to switch, thank you!

z00rat commented 3 years ago

Cool!! you are always welcome to contribute here! BTW, I read more about rolling release operative systems and I just switched to manjaro, I had some problems installing RVM (ruby version manager) because I used to develop on ruby and rails but at the end I was able to solved (reading the Arch Wiki). so far Manjaro is super cool all it's easy with the pamac tool.

You inspired me to switch, thank you!

hahaha its nothing.

manjaro is a good start but dont be there for too long its takes sometime before releasing updates. which is not good for following the archwiki TBH. be on manjaro for leaning the basics then move to pure arch and make the system yours.