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

Cannot run code on php interpreter working in docker #46

Closed
Taalaybek opened this issue Feb 16, 2021 · 28 comments
Closed

Cannot run code on php interpreter working in docker #46

Taalaybek opened this issue Feb 16, 2021 · 28 comments
Labels
bug Something isn't working

Comments

@Taalaybek
Copy link

Bug description
shows a progress but not output result in right window of tinker

To Reproduce
when running code via docker, it is just try up container that I set in settings of php interpretuere

Environment (please complete the following information):

  • IDE & Version: PHPStorm 2020.2.4
  • PHP Version: 7.4
  • OS: Elementary OS 5..1.7 Hera (based on Ubuntu 18.04)
  • Laravel Tinker plugin version : [e.g. 1.1.1]
  • Interpreter TypeDocker / Docker-compose
  • Laravel Version: 8.0
  • Tinker version: 2.0
@Taalaybek Taalaybek added the bug Something isn't working label Feb 16, 2021
@Roboroads
Copy link
Owner

@Taalaybek Can you confirm how you are running docker? If you are using docker run can you try is the issue persists if you use docker exec?

I've had another problem which I can't seem to figure out using docker run.

@Roboroads Roboroads added the need more info I will need a little more information to be able to do or fix this. label Feb 22, 2021
@dmitryuk
Copy link

I'm using docker-compose, running tests from PHPStorm works fine, Laravel tinker 2 - no.

@Roboroads
Copy link
Owner

@dmitryuk That does not really answer my question yet. Are you using docker-compose run or docker-compose exec when running Tinker? You can find it in the PHPStorm interpreter settings.

@dmitryuk
Copy link

docker-compose exec
image

@hailwood
Copy link

On this topic Lando is quite popular,
The issue is that it's a wrapper around docker-compose - so we don't have the docker-compose.yml file

Instead we do things like lando artisan migrate or lando tinker and it will deal with that side for us.
It means we cannot use PHPstorm for running tests etc

I doubt this is something this plugin can solve, but it does prevent us from using it.

@Roboroads
Copy link
Owner

@hailwood True, i'd have to create a switch between "how to run a tinker command" with you being able to add a custom command for executing. If there is enough people wanting that I could add it.

@jdecode
Copy link

jdecode commented May 13, 2021

If you need time/energy/effort to work on this one, I can try to chip in...

@stale
Copy link

stale bot commented Sep 20, 2021

This issue has been automatically marked as stale because it has not had recent activity. This means this issue is resolved or nobody else has had this issue or feature request. It will be closed if no further activity occurs within 30 days, so if this is still relevant, please let us know!

@stale stale bot added the stale This issue hasn't had activity for quite some time - let me know if it's still relevant! label Sep 20, 2021
@hailwood
Copy link

/applyMagicFreshness

@stale stale bot removed the stale This issue hasn't had activity for quite some time - let me know if it's still relevant! label Sep 20, 2021
@Roboroads
Copy link
Owner

@hailwood Thanks for noting. Are you actually having a bug that prevents you from running with Docker, or do you need a way to change the command? If it''s the latter, this is a feature request and not a bug and you should make a new ticket. If it';s the first, please provide the docker container/dockerfile you are trying to run it on 😊

@Roboroads Roboroads changed the title cannot run code on php interpretuere working in docker Cannot run code on php interpreter working in docker Sep 26, 2021
@stale
Copy link

stale bot commented Nov 25, 2021

This issue has been automatically marked as stale because it has not had recent activity. This means this issue is resolved or nobody else has had this issue or feature request. It will be closed if no further activity occurs within 30 days, so if this is still relevant, please let us know!

@stale stale bot added the stale This issue hasn't had activity for quite some time - let me know if it's still relevant! label Nov 25, 2021
@AnthoRdev
Copy link

/applyMagicFreshness

@stale stale bot removed the stale This issue hasn't had activity for quite some time - let me know if it's still relevant! label Dec 5, 2021
@minhnh94
Copy link

minhnh94 commented Jan 4, 2022

CleanShot 2022-01-04 at 12 07 13
Have the same issue, with PHP interpreter coming from docker container. tinker executed but no output. If I change to docker-compose exec it doesn't even run at all.
Which is weird, the exact same setting worked before and I never touched it since then, I wonder if an update on Laravel tinker plugin broke it ... 😞

@Warmic
Copy link

Warmic commented Jan 25, 2022

Hello, I encountered the same problem and fixed it by downgrading PhpStorm version from 2021.3.1 to 2021.2.4. I also tried 2021.3.2 (EAP) it too had this problem

@Warmic
Copy link

Warmic commented Jan 31, 2022

Hey guys,I think I understand now what is going on.
When IDE tries to execute command in fresh docker container, it does following: docker-compose -f "interpreter.docker-compose.yml" -f "ide-created/docker-compose.override.yml" run --rm containerName

This docker-compose.override file contains php code that will be executed. Both from plugin and user-input. Problem happens here. In versions of IDE where plugin works correctly, all variables (e.g. with $ sign) get prefixed by $ twice(so instead of $var = 1, it becomes $$var = 1). Then this code gets executed and works fine. In 2021.3.1 version, however, it gets prefixed 4 times instead of 2. And execution of this code results in nothing, because it fails before it even gets to php. If I replace all 4 consecutive $ by 2, code is executed properly!

Now, I tried to fix it by myself. But unfortunately, was unable to understand which IDE-specific files I should modify.
@Roboroads do you have any thoughts on how it can be fixed?

Here are docker-compose files I was talking about.
invalid compose
valid compose

@Warmic
Copy link

Warmic commented Feb 8, 2022

@Roboroads if you don't know how to solve this problem, I can try to contact some guys from Jetbrains or make an issue on their youtrack page

@Roboroads Roboroads added keep active This issue is exempt from going stale and removed need more info I will need a little more information to be able to do or fix this. labels Feb 12, 2022
@Roboroads
Copy link
Owner

@Warmic That's a good find! I'm going to look into this when I get the time which I currently do not have a lot of.

@JerryBels
Copy link

Hey, in a sail environment on Windows I seem to have a similar issue. Tinker is executed but no output shown and the command actually has no effect (adding something in DB for example doesn't work). I configured my cli interpreter to use docker, but to no avail.

@Roboroads
Copy link
Owner

This PR got me thinking of something. I'll keep everyone posted.

@Roboroads
Copy link
Owner

Roboroads commented May 12, 2022

@Warmic I posted this issue and your findings in their slack channel, no response yet. I have no idea how to het this overrides dockerfile out so if you have time to explain it to me I can maybe add a bug to youtrack myself :) (or you do it, and I back you with "My plugin has this issue", also good 😄 ).

@Roboroads
Copy link
Owner

JB sais it's fixed in PHPStorm 2022.2 EAP Can someone also test it?

@peresmishnyk
Copy link

@Roboroads Testing PHPStorm 2022.2 EAP, not fixed :(

@Roboroads
Copy link
Owner

I'm one step further, I'm certain it has something to do with functions. I rewrote tinker_run.php without declaring functions and it works.

@Roboroads
Copy link
Owner

Roboroads commented Jun 8, 2022

</proffessional>
I. FKN. FIXED. THIS. FINALLY.
FKN. INTELLIJ. WEIRDNESS.
<proffessional>

Ahum. Release is on its way :)

This is a moment of pure joy for me 😄

@Roboroads
Copy link
Owner

Fix is ready and will be released in 2.3.4.

Please let me know if you still have problems, but I hope I can close this one once and for all. It took be more than 40 hours to debug this :D

@Roboroads Roboroads removed the keep active This issue is exempt from going stale label Jun 9, 2022
@Roboroads
Copy link
Owner

Before reopening this bug again, please read this

@JohnLeet
Copy link

Hey guys,I think I understand now what is going on. When IDE tries to execute command in fresh docker container, it does following: docker-compose -f "interpreter.docker-compose.yml" -f "ide-created/docker-compose.override.yml" run --rm containerName

This docker-compose.override file contains php code that will be executed. Both from plugin and user-input. Problem happens here. In versions of IDE where plugin works correctly, all variables (e.g. with $ sign) get prefixed by $ twice(so instead of var=1,itbecomes$var = 1). Then this code gets executed and works fine. In 2021.3.1 version, however, it gets prefixed 4 times instead of 2. And execution of this code results in nothing, because it fails before it even gets to php. If I replace all 4 consecutive $ by 2, code is executed properly!

Now, I tried to fix it by myself. But unfortunately, was unable to understand which IDE-specific files I should modify. @Roboroads do you have any thoughts on how it can be fixed?

Here are docker-compose files I was talking about. invalid compose valid compose

@Warmic @Roboroads
Hello!
I think I got the same issue but instead of 4 dollars ($$$$) I have 4 slashes (////)

If you have free time could you help me?
Environment:

  • Phpstorm 241 (EAP)
  • Windows 11
  • WSL2
  • Sail

Php Cli Interpreter "Docker Compose"

image

@Roboroads
Copy link
Owner

@JohnLeet Add me on Discord - same name as github, we'll look at it together :)

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