bchatard / alfred-jetbrains

Alfred5 workflow to easily open your projects with your favorite JetBrains product.
MIT License
618 stars 49 forks source link

The idea command line does not recognize environmental variables. #333

Closed joel-you closed 8 months ago

joel-you commented 9 months ago

FAQ

Describe the bug

I am using zsh and constructing a project that uses the idea command for custom environment variables included in ~/.zshrc. When intelliJ is turned on using the idea command, the environment variable is not recognized.

However, if intelliJ is turned on without using the idea command, the environmental variables are recognized even if the idea command is used to turn on other projects.

To Reproduce

  1. Put the custom environment variable in ~/.zshrc.
  2. Turn on intelliJ with the idea command line.
  3. Put System.getenv ('environmental variable name') in build.gradle and print it out.
  4. Custom environment variable is output as null.

Expected behavior

  1. After completely shutting down intelliJ, click the toolbox or the intelliJ icon to run it yourself.
  2. The value of the user environment variable is taken when you act like number 3 in To Reproduce.

Alfred Version

5.1.2

Workflow Version

2.0.8

Node Version

v20.6.1

NPM Version

10.1.0

Jetbrains Product & Version

IntelliJ 2023.2.2

Installation type

JetBrains ToolBox

OS

macOS 13.3

bchatard commented 9 months ago

did you test with the bin directly?

pertsim commented 9 months ago

I had the same issue and could fix it by adding a 'source ~/.zshrc` to the run script.

if [[ -n "{query}" ]]; then
    source ~/.zshrc
    QUERY="{query}"
    BIN=${jb_bin}
    PROJECT_NAME=${jb_project_name}
    if [[ "${jb_is_new_bin}" == "1" ]]; then
        open -na "${BIN}" --args "${QUERY}"
    else
        $(${BIN} "${QUERY}")
    fi

    echo "${PROJECT_NAME}"
fi
joel-you commented 9 months ago

I had the same issue and could fix it by adding a 'source ~/.zshrc` to the run script.

if [[ -n "{query}" ]]; then
  source ~/.zshrc
  QUERY="{query}"
  BIN=${jb_bin}
  PROJECT_NAME=${jb_project_name}
  if [[ "${jb_is_new_bin}" == "1" ]]; then
      open -na "${BIN}" --args "${QUERY}"
  else
      $(${BIN} "${QUERY}")
  fi

    echo "${PROJECT_NAME}"
fi

I was solved by the way you told me. Thanks, man.

joel-you commented 9 months ago

did you test with the bin directly?

It was solved this way.

bchatard commented 8 months ago

hi, just push a new version with this fix