Skip to content

#1135: Add PowerShell environment initialization - #2232

Open
cap-juan wants to merge 5 commits into
devonfw:mainfrom
cap-juan:feature/1135-set-env-vars-powershell
Open

#1135: Add PowerShell environment initialization#2232
cap-juan wants to merge 5 commits into
devonfw:mainfrom
cap-juan:feature/1135-set-env-vars-powershell

Conversation

@cap-juan

@cap-juan cap-juan commented Jul 29, 2026

Copy link
Copy Markdown

This PR fixes #1135

Implemented changes:

  • Added PowerShell shell integration for IDEasy.
  • Added automatic IDEasy environment initialization when PowerShell starts inside an IDEasy project.
  • Added PowerShell equivalents for the existing ide, icd, and claude shell functions.
  • Added PowerShell command completion support where supported by the installed PowerShell version.
  • Added automatic configuration and cleanup of the current user's PowerShell profile during installation and uninstallation.
  • Added functions.ps1 to the IDEasy installation artifacts.
  • Kept the PowerShell behavior aligned with the existing Bash integration.

Testing instructions

  1. Check out the PR branch and build/install IDEasy using the normal local development workflow.

  2. Verify that the PowerShell integration script was installed:
    Test-Path "$env:IDE_ROOT\_ide\installation\functions.ps1"

  3. The command should return True.

  4. Close all existing PowerShell sessions.

  5. Open a new PowerShell window directly inside an IDEasy project.

  6. Verify that ide is loaded as a PowerShell function:
    Get-Command ide

  7. The command type should be Function.

  8. Verify that the IDEasy environment was initialized automatically:

$env:IDE_HOME
$env:MAVEN_ARGS
  1. Both variables should contain the values for the current IDEasy project.

  2. Verify that Maven can be executed without running ide first:
    mvn --version

  3. Verify manual environment refresh after changing directories:

Set-Location "$env:IDE_ROOT"
Set-Location "$env:IDE_ROOT\IDEasy"
ide
$env:MAVEN_ARGS
  1. MAVEN_ARGS should be set after running ide.

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

Checklist for tool commandlets

Have you added a new «tool» as commandlet? There are the following additional checks:

  • The tool can be installed automatically (during setup via settings) or via the commandlet call
  • The tool is isolated in its IDEasy project, see Sandbox Principle
  • The new tool is added to the table of tools in LICENSE.asciidoc
  • The new commandlet is a command-wrapper for «tool»
  • Proper help texts for all supported languages are added here
  • The new commandlet installs potential dependencies automatically
  • The variables «TOOL»_VERSION and «TOOL»_EDITION are honored by your commandlet
  • The new commandlet is tested on all platforms it is available for or tested on all platforms that are in scope of the linked issue

@CLAassistant

CLAassistant commented Jul 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cap-juan
cap-juan force-pushed the feature/1135-set-env-vars-powershell branch 2 times, most recently from 2d5eee9 to d7bac43 Compare July 29, 2026 12:04
@coveralls

coveralls commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 31709859615

Coverage increased (+0.06%) to 72.946%

Details

  • Coverage increased (+0.06%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 86 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

86 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/tool/IdeasyCommandlet.java 86 76.1%

Coverage Stats

Coverage Status
Relevant Lines: 17607
Covered Lines: 13393
Line Coverage: 76.07%
Relevant Branches: 7783
Covered Branches: 5128
Branch Coverage: 65.89%
Branches in Coverage %: Yes
Coverage Strength: 3.23 hits per line

💛 - Coveralls

@cap-juan
cap-juan requested a review from samuelkos17 July 29, 2026 13:21
@cap-juan cap-juan moved this from 🆕 New to Team Review in IDEasy board Jul 30, 2026
@cap-juan cap-juan added enhancement New feature or request PowerShell Windows PowerShell integration and support ready-to-implement labels Jul 30, 2026
@cap-juan cap-juan self-assigned this Jul 30, 2026
@samuelkos17 samuelkos17 self-assigned this Jul 31, 2026

@samuelkos17 samuelkos17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! IMHO this is a nice implementation which adds the functionality requested in #1135. I've ran through your test instructions and everything worked perfectly fine. I have a small suggestion though concerning your method structure. Also you could think about adding tests for the changes you made.

Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/IdeasyCommandlet.java
@cap-juan
cap-juan force-pushed the feature/1135-set-env-vars-powershell branch 2 times, most recently from e019779 to 137bc42 Compare August 5, 2026 12:05

@samuelkos17 samuelkos17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for applying my suggestions and writing Unit Tests! However I still think you should change some very minor things. I also suggest that you write an integration test to actually make sure that the file gets modified on disk.

Comment thread CHANGELOG.adoc
Comment thread cli/src/test/java/com/devonfw/tools/ide/tool/IdeasyCommandletPowerShellTest.java Outdated
@cap-juan
cap-juan force-pushed the feature/1135-set-env-vars-powershell branch from 48ee6c2 to d8642f1 Compare August 7, 2026 06:17

@samuelkos17 samuelkos17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changing again, this seems good to me now so I'll move it to In Review. 😄

@samuelkos17 samuelkos17 moved this from Team Review to 👀 In review in IDEasy board Aug 7, 2026
@cap-juan
cap-juan force-pushed the feature/1135-set-env-vars-powershell branch from d8642f1 to b49d20d Compare August 10, 2026 11:36
@cap-juan
cap-juan force-pushed the feature/1135-set-env-vars-powershell branch from b49d20d to 3d8164c Compare August 11, 2026 07:39
@cap-juan
cap-juan force-pushed the feature/1135-set-env-vars-powershell branch from 3d8164c to a21b15a Compare August 11, 2026 07:59

@hohwille hohwille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cap-juan thank you for your PR. This is really great work. You implemented an analogue variant of functions for powershell as functions.ps1 and integrate this with PowerShell during the installation of IDEasy. 👍
Of course the cost of all this is that we now have duplicated maintenance effort for all changes made to functions also in functions.ps1 - esp. since you implemented all features including icd (but AFAIK excluding auto-completion).
However, I would say that we meanwhile reached a state where things like that are somewhat stabilised. Still I fear that with stories like #2050 we might later get some pain with this.
Therefore my question is what will be our new status for PowerShell that was currently "unsupported":

echo %_fBYellow%Please use ^(git-^)bash ^(integrated in Windows Terminal^) for full IDEasy support:
echo https://github.com/devonfw/IDEasy/blob/main/documentation/advanced-tooling-windows.adoc#tabs-for-shells %_RESET%

Do we now also want to build full auto-completion support, etc.?
My initial idea was to rather educate users to use bash as a universal shell:
#1430

Comment on lines +459 to +460
modifyPowerShellProfile("powershell", install);
modifyPowerShellProfile("pwsh", install);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will also run in JUnits and however tweak the real end-users powershell setup.
We want to avoid such side-effects and ensure IdeTestContext ensures encapsulation.
I would therefore suggest to extend this special feature to WindowsHelper that has its own Mock implementation so we do not manipulate or even "destroy" the end-users environment when he executes JUnit tests.

Or am I missing something and this is already mocked away via ProcessContext so the exeuctions of powershell and pwsh will more or less be void?

@hohwille hohwille added this to the release:2026.08.002 milestone Aug 13, 2026
Comment thread CHANGELOG.adoc
Comment on lines +14 to +15
* https://github.com/devonfw/IDEasy/issues/1135[#1135]: IDEasy does not set env variables on Windows PowerShell
* https://github.com/devonfw/IDEasy/issues/1135[#1135]: Fix PowerShell env variable initialization on Windows by sourcing functions from the PowerShell profile

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the issue added twice with different titles?
Also this needs to be moved up to the most current release (Sorry, I was too late with reviews).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PowerShell Windows PowerShell integration and support

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

IDEasy does not set env variables on Windows PowerShell

5 participants