6

I created this simple project in Gitlab:

https://gitlab.com/PequeX/deleteme

With a Pipfile that installs only a couple of packages:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "*"

[packages]
requests = "*"

[requires]
python_version = "3.7"

And a very simple .gitlab-ci.yml file:

image: peque/python-devel

before_script:
  - pipenv sync --dev

python36:
  script:
    - pipenv run pytest

There is also the autogenerated Pipfile.lock file. Which I will not paste here as it is not very interesting.

Now, the problem is Gitlab seems to get blocked when calling pipenv sync:

https://gitlab.com/PequeX/deleteme/-/jobs/171273142

There is no output printed on the log and no error. It just gets blocked forever. And then, eventually, it timeouts (because Gitlab would not let you run a pipeline forever).

What is wrong or how could I successfully run pipenv sync? Note that I would like to keep using the same peque/python-devel image from Docker Hub, as I need to have multiple Python versions installed for my pipelines.

Update

Tried unsetting the CI variable as @Hernan Garcia suggests in his answer, with no luck:

I also tried with pipenv shell as @Hernan Garcia suggests in his comments, with no luck:

Peque
  • 13,638
  • 11
  • 69
  • 105

3 Answers3

5

As mentioned in another answer defining an empty CI variable will solve the build stuck issue.

Then the second issue that you will face due to not finding pytest and this is because the docker image is missing which package and this makes pipenv not able to find pytest.

The final gitlab-ci.yml file should be similar to the following:

image: peque/python-devel

variables:
  CI: ""

before_script:
  - pipenv sync --dev
  - yum install -y which

python36:
  script:
    - pipenv run pytest

And the final output will be:

$ pipenv run pytest
============================= test session starts ==============================
platform linux -- Python 3.7.2, pytest-4.3.0, py-1.8.0, pluggy-0.9.0
rootdir: /builds/mostafahussein/deleteme, inifile:
collected 0 items

========================= no tests ran in 0.01 seconds =========================


Regarding this issue:
termios.error: (25, 'Inappropriate ioctl for device')

This is because pipenv shell needs a tty to run without raising the above error however GitLab CI does not provide a tty since there are no user inputs as far as i know. So it will be better to use the first method which is pipenv run.

Mostafa Hussein
  • 11,063
  • 3
  • 36
  • 61
  • Does fix the issue, thanks. Still have to figure out what is the difference between this (perhaps too) reduced example and the real repository, which is now (after installing `which`) failing with a "core dumped" error as soon as I run the `pipenv` command. :'( – Peque Mar 07 '19 at 13:18
  • @Peque I have pulled the current docker image and everything works as expected no need to install which because i found it exist already as i can see you have pushed a new image `b7c96e8d2b98`. What is your current issue as I cannot reproduce the "core dumped" error – Mostafa Hussein Mar 07 '19 at 13:39
  • Yeah, I updated the image with the missing `which`, thanks. I need to work a bit on trying to produce a reduced example that would reproduce the "core dumped". I will accept your answer for now, as it currently fixes all reproducible issues. – Peque Mar 07 '19 at 14:20
  • @Peque please don't forget to add the bounty as it should be added manually and up-vote the answer. – Mostafa Hussein Mar 07 '19 at 15:48
  • I already upvoted the answer. I am still thinking whether or not to award the bounty. If I do not award it, it will be split between you and @hernangarcia, who also helped with the `CI` variable problem. ^^ – Peque Mar 07 '19 at 16:03
1

I could fix it by using this workaround:
https://github.com/pypa/pipenv/issues/3534#issuecomment-464510351

Add the following to your .gitlab-ci.yml file to unset CI variable:

variables:
    CI: ""

Check this succeeded job:
https://gitlab.com/hernandanielg/deleteme/-/jobs/171342796

;)

Hernan Garcia
  • 1,416
  • 1
  • 13
  • 24
  • I will try that workaround, thanks! I swear I searched for `pipenv` issues, but I think I searched for the word "block", not "stuck" and that issue did not come up... :-/ – Peque Mar 04 '19 at 16:49
  • I updated the repository a bit [by actually trying to use some installed package](https://gitlab.com/PequeX/deleteme/tree/hernan). Now it does not get stuck, but it says it cannot find the (supposedly correctly) installed package. Any ideas? – Peque Mar 04 '19 at 17:18
  • if I do `pipenv shell` and then `pytest` it works... to use `pipenv run pytest` seems an issue with pip – Hernan Garcia Mar 04 '19 at 19:52
  • An issue with `pip` and not `pipenv` in that case? Should it be reported? I always thought `pipenv shell + xxx` was equivalent to `pipenv run xxx`. – Peque Mar 05 '19 at 09:08
  • I don't know for sure but I tried on the container image you're using and it was failing too so it's not related to gitlab-ci at all – Hernan Garcia Mar 05 '19 at 13:41
  • [I tried running `pipenv shell`](https://gitlab.com/PequeX/deleteme/tree/cishell), but [it crashes too](https://gitlab.com/PequeX/deleteme/-/jobs/172044675). :-/ – Peque Mar 05 '19 at 15:10
-1

You need to change the file permission. make it as readable and writable use chmod 777 command. which will give the file full permissions to read and write

  • Which file you mean? – Peque Mar 13 '19 at 08:57
  • whole docker file change the mode –  Mar 13 '19 at 10:54
  • You mean the `Dockerfile`? That is only used to generate the image that is already in Docker Hub, how could that be related to the problem in Gitlab? – Peque Mar 13 '19 at 11:25
  • the basic problem with docker file is it does not have the full permission to execute the job. when i was working on aws batch i have faced this issue so file which is inside docker file, as well as whole docker image, give the full read-write access. i.e Chmod 777 –  Mar 13 '19 at 11:27
  • before execting on gitlab give full access to docker image –  Mar 13 '19 at 11:29
  • Gitlab has access to the Docker image. It downloads and runs it without any issues. The issue is with Pipenv. I still do not know which file you mean by "file which is inside docker file". – Peque Mar 13 '19 at 12:34
  • Please change the file permission to chmod 777. before creating the docker file change the file permission of all the files. this issue occurs due to insufficient file permission. –  Mar 18 '19 at 05:17