playframework / play1

Play framework
https://www.playframework.com/documentation/1.4.x/home
Other
1.58k stars 683 forks source link

"play new" does not run #1493

Open phaus opened 1 month ago

phaus commented 1 month ago

Play Version

1.7.1 1.8.0

Describe the bug play new should create a new application. Instead the following error is displayed:

(base) philipp@Imotep /tmp % play new app1
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.8.0, https://www.playframework.com
~
~ The new application will be created in /private/tmp/app1
~ What is the application name? [app1]
Traceback (most recent call last):
  File "/Users/philipp/.bin/play/play", line 168, in <module>
    status = cmdloader.commands[play_command].execute(command=play_command, app=play_app, args=remaining_args, env=play_env, cmdloader=cmdloader)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/philipp/.bin/play/framework/pym/play/commands/base.py", line 38, in execute
    new(app, args, env, cmdloader)
  File "/Users/philipp/.bin/play/framework/pym/play/commands/base.py", line 95, in new
    os.mkdir(os.path.join(app.path, 'app/models'))
FileNotFoundError: [Errno 2] No such file or directory: '/private/tmp/app1/app/models'

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

or

Please provide a PR with a failing test.

If the issue is more complex or requires configuration, please provide a link to a project on Github that reproduces the issue.

Expected behavior The app is created

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

jacol84 commented 1 month ago

image it works for me

I would bet on permissions because it didn't create a folder for you FileNotFoundError: [Errno 2] No such file or directory: '/private/tmp/app1/app/models'

phaus commented 1 month ago

Hi @jacol84 - thx for the response…

I did another test, in my home directory… see the permissions, the same result.

% ls -al
total 0
drwxr-xr-x  2 philipp  staff   64 14 Aug 08:23 .
drwxr-xr-x  6 philipp  staff  192 14 Aug 08:23 ..
(base) philipp@Imotep play-app % play new foo1
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.8.0, https://www.playframework.com
~
~ The new application will be created in /Users/philipp/tmp/play-app/foo1
~ What is the application name? [foo1]
Traceback (most recent call last):
  File "/Users/philipp/.bin/play/play", line 168, in <module>
    status = cmdloader.commands[play_command].execute(command=play_command, app=play_app, args=remaining_args, env=play_env, cmdloader=cmdloader)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/philipp/.bin/play/framework/pym/play/commands/base.py", line 38, in execute
    new(app, args, env, cmdloader)
  File "/Users/philipp/.bin/play/framework/pym/play/commands/base.py", line 95, in new
    os.mkdir(os.path.join(app.path, 'app/models'))
FileNotFoundError: [Errno 2] No such file or directory: '/Users/philipp/tmp/play-app/foo1/app/models'

Any idea, where I can start to have a look why this does not work?

jacol84 commented 3 weeks ago

@phaus Hey after the script play new foo1 do ls -al -R

phaus commented 3 weeks ago

To me it looks like something is just not created:

(base) philipp@Imotep play-test % play new foo1
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.8.0, https://www.playframework.com
~
~ The new application will be created in /private/tmp/play-test/foo1
~ What is the application name? [foo1]
Traceback (most recent call last):
  File "/Users/philipp/.bin/play/play", line 168, in <module>
    status = cmdloader.commands[play_command].execute(command=play_command, app=play_app, args=remaining_args, env=play_env, cmdloader=cmdloader)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/philipp/.bin/play/framework/pym/play/commands/base.py", line 38, in execute
    new(app, args, env, cmdloader)
  File "/Users/philipp/.bin/play/framework/pym/play/commands/base.py", line 95, in new
    os.mkdir(os.path.join(app.path, 'app/models'))
FileNotFoundError: [Errno 2] No such file or directory: '/private/tmp/play-test/foo1/app/models'
(base) philipp@Imotep play-test % ls -al -R
total 0
drwxr-xr-x   3 philipp  wheel   96 19 Aug 08:24 .
drwxrwxrwt  10 root     wheel  320 19 Aug 08:24 ..
drwxr-xr-x   2 philipp  wheel   64 19 Aug 08:24 foo1

./foo1:
total 0
drwxr-xr-x  2 philipp  wheel  64 19 Aug 08:24 .
drwxr-xr-x  3 philipp  wheel  96 19 Aug 08:24 ..

play run works fine with existing projects.

jacol84 commented 3 weeks ago

how could you change in Users/philipp/.bin/play/framework/pym/play/commands/base.py line 95 of the code os.mkdir(os.path.join(app.path, 'app/models')) and add above it os.mkdir(os.path.join(app.path, 'app'))

image

phaus commented 3 weeks ago

Thx. So I did not got the error. However, the generated app does not seem to be complete:

(base) philipp@Imotep /tmp % play new foo
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.8.0, https://www.playframework.com
~
~ The new application will be created in /private/tmp/foo
~ What is the application name? [foo]
~ Oops. conf/routes or conf/application.conf missing.
~ /private/tmp/foo does not seem to host a valid application.
~
(base) philipp@Imotep /tmp % tree -L 4 foo
foo
├── app
│   └── models
└── lib

4 directories, 0 files
jacol84 commented 3 weeks ago

maybe you need to create all folders

├───app │ ├───controllers │ ├───models │ └───views │ ├───Application │ └───errors ├───conf ├───documentation │ ├───files │ └───images ├───lib ├───modules ├───public │ ├───images │ ├───javascripts │ └───stylesheets └───test

image

    os.mkdir(os.path.join(app.path, 'app'))
    os.mkdir(os.path.join(app.path, 'app/controllers'))
    os.mkdir(os.path.join(app.path, 'app/models'))
    os.mkdir(os.path.join(app.path, 'app/views'))
    os.mkdir(os.path.join(app.path, 'app/views/Application'))
    os.mkdir(os.path.join(app.path, 'app/views/errors'))
    os.mkdir(os.path.join(app.path, 'conf'))
    os.mkdir(os.path.join(app.path, 'documentation'))
    os.mkdir(os.path.join(app.path, 'documentation/files'))
    os.mkdir(os.path.join(app.path, 'documentation/images'))
    os.mkdir(os.path.join(app.path, 'modules'))
    os.mkdir(os.path.join(app.path, 'public'))
    os.mkdir(os.path.join(app.path, 'public/images'))
    os.mkdir(os.path.join(app.path, 'public/javascripts'))
    os.mkdir(os.path.join(app.path, 'public/stylesheets'))
    os.mkdir(os.path.join(app.path, 'test'))
    os.mkdir(os.path.join(app.path, 'lib'))
jacol84 commented 2 weeks ago

@phaus it is working?

phaus commented 2 weeks ago

Hi @jacol84 I don't really get it. Until play 1.4.x, the play new cmd did generate the whole folder strucutre. So were there some changes there?

With your changes, the folder structure is there, but now config files (aka application.conf or dependencies.yml). To me, it looks like the application skeleton is not used at all to setup a new app? 🤔

jacol84 commented 1 week ago

there have been changes system python is used and not the version of play that was provided as before (play 1.4 with python 2.x) (play 1.5+ is without python) now python is required in version 3

update your python version to the latest one, maybe that will help

xael-fry commented 1 week ago

the copy_directory doesn't seems to work, could you tell me if /Users/philipp/.bin/play/resources/application-skel exist and what is the content of this directory ?

phaus commented 1 week ago

Sure… I am a little bit covered in work right now. If I can test anything, I will be able to do that end of this week. Please see content of /Users/philipp/.bin/play/resources/application-skel:

philipp@MacLab resources % tree -L 3
.
├── _nbproject
│   └── project.xml
├── application-build.xml
├── application-skel
│   ├── app
│   │   ├── controllers
│   │   └── views
│   ├── conf
│   │   ├── application.conf
│   │   ├── dependencies.yml
│   │   ├── messages
│   │   └── routes
│   ├── documentation
│   │   ├── files
│   │   ├── images
│   │   ├── template.html
│   │   └── welcome.textile
│   ├── public
│   │   ├── images
│   │   ├── javascripts
│   │   └── stylesheets
│   └── test
│       ├── Application.test.html
│       ├── ApplicationTest.java
│       ├── BasicTest.java
│       └── data.yml
├── build.xml
├── eclipse
│   ├── connect.launch
│   ├── debug.launch
│   └── test.launch
├── idea
│   ├── imlTemplate.xml
│   └── iprTemplate.xml
├── messages
├── module-skel
│   ├── build.xml
│   ├── commands.py
│   ├── conf
│   │   ├── dependencies.yml
│   │   ├── messages
│   │   └── routes
│   ├── documentation
│   │   └── manual
│   └── src
│       └── play.plugins
└── war
    └── web.xml
phaus commented 1 week ago

I am using a link to the recent play version (what worked in the past) Like this:

philipp@MacLab ~ % ls -al ~/.bin  |grep play
lrwxr-xr-x@   1 philipp  staff        10 21 Aug 14:26 play -> play-1.8.0
drwxr-xr-x@  14 philipp  staff       448  1 Mär  2024 play-1.8.0

Maybe that is causing some issues?

PLAY_HOME is set correctly to PLAY_HOME=/Users/philipp/.bin/play-1.8.0