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

[BUG] Exception thrown in PHPStorm with 'Use .gitignore' enabled #554

Open
axymthr opened this issue Mar 4, 2025 · 6 comments
Open

[BUG] Exception thrown in PHPStorm with 'Use .gitignore' enabled #554

axymthr opened this issue Mar 4, 2025 · 6 comments
Labels
bug Something isn't working

Comments

@axymthr
Copy link

axymthr commented Mar 4, 2025

PhpStorm 2024.3.4
Build #PS-243.25659.45, built on February 27, 2025
Runtime version: 21.0.6+8-b631.39 aarch64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 15.3.1
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 8
Metal Rendering is ON
Registry:
run.processes.with.pty=TRUE
ide.experimental.ui=true
Non-Bundled Plugins:
com.jetbrains.edu (2025.2-2024.3-1399)
com.devoxx.genie (0.4.20)

In Settings > 'Scan & Copy Project' > with Use .gitignore enabled following error is thrown for specific 'Add to prompt context' actions and 'Calc Tokens' does not work.

java.lang.IllegalArgumentException: The requested file "/Users/<username>/PhpstormProjects/empty" is not relative to project root and is NOT in the projectBaseDir "<omitted for privacy>"
	at nl.basjes.gitignore.GitIgnoreFileSet.getProjectRelative(GitIgnoreFileSet.java:243)
	at nl.basjes.gitignore.GitIgnoreFileSet.isIgnoredFile(GitIgnoreFileSet.java:171)
	at nl.basjes.gitignore.GitIgnoreFileSet.ignoreFile(GitIgnoreFileSet.java:202)
	at nl.basjes.gitignore.GitIgnoreFileSet.ignoreFile(GitIgnoreFileSet.java:190)
	at com.devoxx.genie.service.projectscanner.FileScanner.shouldExcludeFile(FileScanner.java:222)
	at com.devoxx.genie.service.projectscanner.FileScanner.generateSourceTreeRecursive(FileScanner.java:158)
	at com.devoxx.genie.service.projectscanner.ProjectScannerService.scanContent(ProjectScannerService.java:82)
	at com.devoxx.genie.service.projectscanner.ProjectScannerService.lambda$scanProject$0(ProjectScannerService.java:55)
	at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:54)
	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runReadAction(AnyThreadWriteThreadingSupport.kt:272)
	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runReadAction(AnyThreadWriteThreadingSupport.kt:262)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:864)
	at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:66)
	at com.intellij.openapi.application.ReadAction.run(ReadAction.java:53)
	at com.devoxx.genie.service.projectscanner.ProjectScannerService.scanProject(ProjectScannerService.java:50)
	at com.devoxx.genie.service.ProjectContentService.getProjectContent(ProjectContentService.java:44)
	at com.devoxx.genie.service.TokenCalculationService.calculateTokensAndCost(TokenCalculationService.java:37)
	at com.devoxx.genie.controller.TokenCalculationController.calculateTokensAndCost(TokenCalculationController.java:48)
	at com.devoxx.genie.controller.ActionButtonsPanelController.calculateTokensAndCost(ActionButtonsPanelController.java:172)
	at com.devoxx.genie.ui.panel.ActionButtonsPanel.lambda$createButtons$1(ActionButtonsPanel.java:107)
...

Error goes away on disabling the Use .gitignore checkbox.
Possibly a minor issue? Suspected it could be due to legacy nature of PHP codebase, but could just be due to missing .gitignore file?

@stephanj
Copy link
Collaborator

stephanj commented Mar 5, 2025

Can you try adding a .gitignore for clarifying the issue? Thanks for reporting this.

@stephanj stephanj added the bug Something isn't working label Mar 5, 2025
@stephanj
Copy link
Collaborator

stephanj commented Mar 5, 2025

I'm unable to reproduce it, any chance you can replicate it with a small project that you could share with me?

@axymthr
Copy link
Author

axymthr commented Mar 6, 2025

The error seems to happen inconsistently. Did manage to replicate it again in a sample project. Attaching the project code.

empty.zip

Enabled the 'Use .gitignore' toggle and tried the 'Add Directory to Prompt Context' action on the project root directory and it threw the following error:

java.lang.IllegalArgumentException: The requested file "/Users/username/PhpstormProjects/empty" is not relative to project root and is NOT in the projectBaseDir "/Users/username/PhpstormProjects/empty/.idea"
	at nl.basjes.gitignore.GitIgnoreFileSet.getProjectRelative(GitIgnoreFileSet.java:243)
	at nl.basjes.gitignore.GitIgnoreFileSet.isIgnoredFile(GitIgnoreFileSet.java:171)
	at nl.basjes.gitignore.GitIgnoreFileSet.ignoreFile(GitIgnoreFileSet.java:202)
	at nl.basjes.gitignore.GitIgnoreFileSet.ignoreFile(GitIgnoreFileSet.java:190)
	at com.devoxx.genie.service.projectscanner.FileScanner.shouldExcludeFile(FileScanner.java:222)
	at com.devoxx.genie.service.projectscanner.FileScanner.generateSourceTreeRecursive(FileScanner.java:158)
	at com.devoxx.genie.service.projectscanner.ProjectScannerService.scanContent(ProjectScannerService.java:88)
	at com.devoxx.genie.service.projectscanner.ProjectScannerService.lambda$scanProject$0(ProjectScannerService.java:55)
	at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:54)
	at 
etc.

It's possible it only happens with this action on the project root. The other actions on project root - For instance, Copy Directory to Clipboard - seem to not work inconsistently but don't throw this error.
Restarted the IDE and it threw the error the first time, but then worked fine on successive attempts. So it is tricky to replicate.

@stephanj
Copy link
Collaborator

Because it's low priority I will freeze my investigation for now. Maybe others will pick this up.
Thanks for sharing!

@axymthr
Copy link
Author

axymthr commented Mar 11, 2025

Thanks. Apologies for only skimming the README, but if there's a plugin debug guide you can point me to, I can try to debug it myself, and maybe suggest a patch.

@stephanj
Copy link
Collaborator

stephanj commented Mar 11, 2025

  1. Fork the project
  2. Open the project in IDEA (the java IDE)
  3. Set your debug breakpoint(s)
  4. Go to the Gradle sidebar menu and click on "runIde" in the IntelliJ group

This will open another IDEA instance but which now runs in debug mode with DevoxxGenie pre-installed.
However if this issue only happens in PhpStorm it might not occur in the Java IDEA...

You could also add more debug logs build plugin using Gradle "buildPlugin" (in the IntelliJ group) and then install it in PhpStorm.

Image Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants