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

Use erl to retrieve OTP_RELEASE & ERLANG_SDK_HOME if no environment variable is set when testing #3600

Merged

Conversation

joshuataylor
Copy link
Collaborator

@joshuataylor joshuataylor commented Jul 14, 2024

Problem

Currently, the ERLANG_SDK_HOME and OTP_RELEASE environment variables need to be set manually when developing and are set in CI.

Example of current setup:

export ERLANG_SDK_HOME="/home/user/.local/share/mise/installs/erlang/24.3.4.6"
export OTP_VERSION="24.3.4.6"

This then breaks when running gradle test without these.

Solution

This PR implements a quick approach to determine the Erlang SDK home and OTP release version:

  1. It first checks for the ERLANG_SDK_HOME and OTP_RELEASE environment variables.
  2. If these are not set, it attempts to infer the values using the erl command, which is likely already in the user's PATH.

This change provides a quick and pragmatic fix to improve the developer experience, especially for those who already have Erlang installed and configured in their environment.

Implementation Details

  • Added methods to infer ERLANG_SDK_HOME and OTP_RELEASE using erl command if environment variables are not set.
  • Implemented caching for OTP release version to avoid repeated calls.
  • Added error handling and appropriate exceptions for cases where values cannot be determined.

Future Improvements

As this is a 5 minute patch, let's improve this code once 2024.x etc is out.

@joshuataylor joshuataylor merged commit 9875d18 into KronicDeth:main Jul 14, 2024
2 checks passed
rNoz pushed a commit to rNoz/intellij-elixir that referenced this pull request Jul 27, 2024
joshuataylor added a commit that referenced this pull request Aug 3, 2024
… Comment) (#3582)

* feat: enabling proper code generation for comments (toggleable, Comment with Line/Block Comment)

* Add the correct ERL and elixir arguments for starting IEx depending on the version of elixir sdk

* Bundle latest OtpErlang.jar from JInterface v1.14 for OTP v26

* Infer OTP_RELEASE & ERLANG_SDK_HOME if no environment variable is set (#3600)

* Add compatibility for 2024.1 IDEs (#3569)

* Update gradlewrapper to v7.6.4
./gradlew wrapper --gradle-version=7.6.4
To fix gradle issue: gradle/gradle#27156

* Remove use of `FileUtil.FILE_HASHING_STRATEGY` from Intellij FileUtil, it was removed in 2024.1. (Note, this is only used in the jps-build test suite).
This also removes references to Trove THashSet, and no longer stores File directly in sets or collections.
See JetBrains/intellij-community@560e8fc

* Add support for 2024.1 IDEs (and runs tests correctly against 2024.1)

* Update usages group wording for 2024.1

* Fix more sdk configuration commits in application RW thread, fixes compatibility with IDEs v2024.1

* Fix whitespace in tests due to 2024.1 change

I believe 2024.1 changed how the Usages work.

In 2023.x:
```kotlin
val usages =
myFixture.testFindUsagesUsingAction("module_attribute_usage.ex",
"kernel.ex")
.map { it as UsageInfo2UsageAdapter }
```

In the debugger shows:
```
0 = {ReadWriteAccessUsageInfo2UsageAdapter@19239} "4|def usage, |do|:
|@|module_attribute"
1 = {ReadWriteAccessUsageInfo2UsageAdapter@19240} "2|@|module_attribute|
|1"
```

For 2024.1, this shows:
```
0 = {ReadWriteAccessUsageInfo2UsageAdapter@19421} "2|
|@module_attribute| 1"
1 = {ReadWriteAccessUsageInfo2UsageAdapter@19422} "4|  def usage, do:
|@module_attribute"
```

I believe it not shows the whitespace for the file, where previously it
didn't.

* pin versions

* use BasePlatformTestCase to stop warning

* add do block match test

* set 241.0 as the version, to fix certain intellij warnings

* fix key

* revert tests

* use thread

---------

Co-authored-by: Josh Taylor <joshuataylorx@gmail.com>

* Add 18.0.0 changelog, fix version (#3602)

* support only the newest version.

* remove tests for now, kind of pointless

---------

Co-authored-by: Ashley Sommer <ashleysommer@gmail.com>
Co-authored-by: Josh Taylor <joshuataylorx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant