Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The extensions.js file throws an error when i try to run an extension #77

Closed
AbegaM opened this issue Dec 10, 2022 · 6 comments
Closed
Assignees
Labels
question Further information is requested

Comments

@AbegaM
Copy link
Collaborator

AbegaM commented Dec 10, 2022

Describe the bug

I am trying to run a soul extension inside the soul/core folder but the code is throwing an error in the /core/src/extensions.js file, i have followed the instructions in here to run the extension.

To Reproduce

  1. Go to the soul/core folder and create a folder named _extensions

  2. Create a file named api.js inside the _extensions folder and copy and paste the sample extension code from here

  3. Add the path of your extension in your .env file

    EXTENSIONS=./_extensions
    
  4. Run the project

    npm run dev
    

Expected behavior
When i run the project, it throws an error in this line, it can't require the _extensions/api.js file,

Screenshots
Screen Shot 2022-12-10 at 10 58 50 PM

Additional context
The code works fine when i modify the path of the extension like this

- const apiExtensions = require(`${extensionsPath}/${extension}`);

+ const apiExtensions = require(`../${extensionsPath}/${extension}`);
@AbegaM AbegaM changed the title The soul/core/src/extensions.js file throws an error when i try to run an extension The extensions.js file throws an error when i try to run an extension Dec 10, 2022
@thevahidal thevahidal self-assigned this Dec 11, 2022
@thevahidal thevahidal added the bug Something isn't working label Dec 11, 2022
@thevahidal
Copy link
Owner

Hi @AbegaM,
you should provide the "absolute" path.
e.g. EXTENSIONS=/home/user/soul/core/_extensions

@thevahidal
Copy link
Owner

Just updated the https://github.com/thevahidal/soul/blob/main/docs/extensions-examples.md to mention the importance of absolute paths for the extensions directory.

@thevahidal thevahidal added question Further information is requested and removed bug Something isn't working labels Dec 11, 2022
@AbegaM
Copy link
Collaborator Author

AbegaM commented Dec 11, 2022

@thevahidal Thank you so much for your answer. I just changed it to an absolute path and everything is working fine now.

@IanMayo
Copy link
Collaborator

IanMayo commented Dec 11, 2022

Hello @thevahidal - is there a strong technical reason why the path has to be absolute?

It can make deployment of a Soul-based solution more challenging - including the fact that extensions will not work "out of the box" on a clone of the repo (since we can't forecast the directory structure above the repo).

@thevahidal
Copy link
Owner

Hey @IanMayo,
No there's not a strong reason behind it, it was just easier as Soul is basically a CLI.
But I can change it so it supports relative paths from where you run the CLI.

@thevahidal
Copy link
Owner

Hey @IanMayo, No there's not a strong reason behind it, it was just easier as Soul is basically a CLI. But I can change it so it supports relative paths from where you run the CLI.

Issue created.
#78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants