question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow environment variable use in dictionary definitions

See original GitHub issue

Is your feature request related to a problem? Please describe. I am using cspell in a github action, and I would like to allow repositories that use the action to provide a custom dictionary in addition to the dictionaries that the action provides.

Describe the solution you’d like I would like the ability to use environment variables in a dictionary definition path.

Describe alternatives you’ve considered Attempted a partial workaround using ~, but that expands to the $HOME for the root user (/root), but we need the runner home dir. Using ~runner resulted in /rootrunner.

I also attempted to glob the directories that change per-github action user in the dictionary definition (with a hard coded home directory due to the above issue) via /home/runner/work/*/*/.github/etc/dictionary.txt and received the following:

Dictionary Error with (per-repository dictionary) Error: ENOENT: no such file or directory, open '/home/runner/work/*/*/.github/etc/dictionary.txt'

Note that dictionary.txt is anticipated to be in ${GITHUB_WORKSPACE}/.github/etc/dictionary.txt during the GitHub actions run. I was able to confirm that this file did exist there as expected during my testing; I have avoided any workarounds using symlinks so far.

Additional context packages/cspell-lib/src/util/resolveFile.ts appears to have very specific support for ^~ only, which uses $HOME and is the closest support to this request that I could find.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Jason3Scommented, Feb 9, 2021

I took a quick look at your pull request.

I see that the cspell config file is part of the action and not part of the repository. In that case relative path won’t exactly work.

You can also use a cspell.config.js file instead of a .json file.

'use strict';

/** @type { import("@cspell/cspell-types").CSpellUserSettings } */
const cspell = {
    description: 'Example config using environment variables.',
    dictionaryDefinitions: [
        {
            name: 'repo-dict',
            path: `${process.env['GITHUB_WORKSPACE']}/.github/etc/dictionary.txt`,
        },
    ],
    dictionaries: ['repo-dict'],
};

module.exports = cspell;
0reactions
github-actions[bot]commented, Aug 14, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to store a Python dictionary as an Environment Variable
You can access the environment using os module's environ attribute. You can dump/load JSON using the json module.
Read more >
Working with Environment Variables in Python - Twilio
Using the os.environ dictionary. In Python, the os.environ dictionary contains all the environment variables. The simplest way to retrieve a ...
Read more >
The environment dictionary, env - Fabric documentation
Most of Fabric's behavior is controllable by modifying env variables, such as env.hosts ... To apply it to a few lines of code,...
Read more >
Using Environment Variables in Python for App Configuration ...
Environment variables in Python are accessed using the os.environ object. The os.environ object seems like a dictionary but is different as ...
Read more >
Environment Variables - The Open Group Publications Catalog
Environment variables that apply to a single utility only are defined as part of the utility description. See the ENVIRONMENT VARIABLES section of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found