nikspyratos / toybox

Opinionated TALL stack starter kit for Laravel solopreneurs
MIT License
117 stars 6 forks source link

Error on bin/init_dev.sh #1

Closed thephilluk closed 11 months ago

thephilluk commented 11 months ago

Hi there,

I just found this Repo and it sounds really interesting. However I can't get it to run right now. I cloned the Repo, changed the Hostname in the Caddyfile and the templates/horizon.conf, and tried running the ./bin/init_dev.sh and get the following output:

App Name: LaravelTest
Domain (WITHOUT 'https:// or www.'): [HOSTNAME WITHOUT PREFIXES]
Database name: laravel
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
sed: -e expression #1, char 1: unknown command: `.'
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - filament/support is locked to version v3.0.34 and an update of this package was not requested.
    - filament/support v3.0.34 requires ext-intl * -> it is missing from your system. Install or enable PHP's intl extension.
  Problem 2
    - filament/support v3.0.34 requires ext-intl * -> it is missing from your system. Install or enable PHP's intl extension.
    - filament/widgets v3.0.34 requires filament/support v3.0.34 -> satisfiable by filament/support[v3.0.34].
    - filament/widgets is locked to version v3.0.34 and an update of this package was not requested.

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/8.2/cli/php.ini
    - /etc/php/8.2/cli/conf.d/10-mysqlnd.ini
    - /etc/php/8.2/cli/conf.d/10-opcache.ini
    - /etc/php/8.2/cli/conf.d/10-pdo.ini
    - /etc/php/8.2/cli/conf.d/15-xml.ini
    - /etc/php/8.2/cli/conf.d/20-bcmath.ini
    - /etc/php/8.2/cli/conf.d/20-bz2.ini
    - /etc/php/8.2/cli/conf.d/20-calendar.ini
    - /etc/php/8.2/cli/conf.d/20-ctype.ini
    - /etc/php/8.2/cli/conf.d/20-curl.ini
    - /etc/php/8.2/cli/conf.d/20-dom.ini
    - /etc/php/8.2/cli/conf.d/20-exif.ini
    - /etc/php/8.2/cli/conf.d/20-ffi.ini
    - /etc/php/8.2/cli/conf.d/20-fileinfo.ini
    - /etc/php/8.2/cli/conf.d/20-ftp.ini
    - /etc/php/8.2/cli/conf.d/20-gd.ini
    - /etc/php/8.2/cli/conf.d/20-gettext.ini
    - /etc/php/8.2/cli/conf.d/20-iconv.ini
    - /etc/php/8.2/cli/conf.d/20-mbstring.ini
    - /etc/php/8.2/cli/conf.d/20-mcrypt.ini
    - /etc/php/8.2/cli/conf.d/20-mysqli.ini
    - /etc/php/8.2/cli/conf.d/20-pdo_mysql.ini
    - /etc/php/8.2/cli/conf.d/20-phar.ini
    - /etc/php/8.2/cli/conf.d/20-posix.ini
    - /etc/php/8.2/cli/conf.d/20-readline.ini
    - /etc/php/8.2/cli/conf.d/20-shmop.ini
    - /etc/php/8.2/cli/conf.d/20-simplexml.ini
    - /etc/php/8.2/cli/conf.d/20-sockets.ini
    - /etc/php/8.2/cli/conf.d/20-sysvmsg.ini
    - /etc/php/8.2/cli/conf.d/20-sysvsem.ini
    - /etc/php/8.2/cli/conf.d/20-sysvshm.ini
    - /etc/php/8.2/cli/conf.d/20-tokenizer.ini
    - /etc/php/8.2/cli/conf.d/20-xmlreader.ini
    - /etc/php/8.2/cli/conf.d/20-xmlwriter.ini
    - /etc/php/8.2/cli/conf.d/20-xsl.ini
    - /etc/php/8.2/cli/conf.d/20-zip.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-intl` to temporarily ignore these required extensions.

up to date, audited 118 packages in 741ms

21 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> build
> vite build

vite v4.4.7 building for production...
transforming (32) node_modules/axios/lib/helpers/AxiosURLSearchParams.jsUnable to resolve `@import "../../../../vendor/filament/filament/resources/css/theme.css"` from /home/code/vscode/test/toybox/resources/css/filament/admin
✓ 35 modules transformed.
✓ built in 1.78s
[vite:css] [postcss] ENOENT: no such file or directory, open '../../../../vendor/filament/filament/resources/css/theme.css'
file: /home/code/vscode/test/toybox/resources/css/filament/admin/theme.css:undefined:undefined
error during build:
Error: [postcss] ENOENT: no such file or directory, open '../../../../vendor/filament/filament/resources/css/theme.css'
PHP Warning:  require(/home/code/vscode/test/toybox/vendor/autoload.php): Failed to open stream: No such file or directory in /home/code/vscode/test/toybox/artisan on line 18
PHP Fatal error:  Uncaught Error: Failed opening required '/home/code/vscode/test/toybox/vendor/autoload.php' (include_path='.:/usr/share/php') in /home/code/vscode/test/toybox/artisan:18
Stack trace:
#0 {main}
  thrown in /home/code/vscode/test/toybox/artisan on line 18
PHP Warning:  require(/home/code/vscode/test/toybox/vendor/autoload.php): Failed to open stream: No such file or directory in /home/code/vscode/test/toybox/artisan on line 18
PHP Fatal error:  Uncaught Error: Failed opening required '/home/code/vscode/test/toybox/vendor/autoload.php' (include_path='.:/usr/share/php') in /home/code/vscode/test/toybox/artisan:18
Stack trace:
#0 {main}
  thrown in /home/code/vscode/test/toybox/artisan on line 18
PHP Warning:  require(/home/code/vscode/test/toybox/vendor/autoload.php): Failed to open stream: No such file or directory in /home/code/vscode/test/toybox/artisan on line 18
PHP Fatal error:  Uncaught Error: Failed opening required '/home/code/vscode/test/toybox/vendor/autoload.php' (include_path='.:/usr/share/php') in /home/code/vscode/test/toybox/artisan:18
Stack trace:
#0 {main}
  thrown in /home/code/vscode/test/toybox/artisan on line 18
Done! See above for any potential errors.

PHP and Composer Version:

Copyright (c) The PHP Group
Zend Engine v4.2.4, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.4, Copyright (c), by Zend Technologies
code@Mailcow:~/vscode/test/toybox$ composer --version
Composer version 2.5.4 2023-02-15 13:10:06

Ubuntu Version:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:        22.04
Codename:       jammy

I think this might be User Error, but I am stuck rn.

nikspyratos commented 11 months ago

Thanks for trying out the project!

The main issue that's causing the rest of it seems to be that you don't have the intl extension installed. That causes composer install to fail, which causes the Vite build to fail because Filament isn't installed.

If you install php8.2-intl, does the script work?

Might need to update the documentation with all the required extensions involved, didn't think of that as I have a few installed by default. I haven't tested the dev setup outside of macOS as I don't have an Ubuntu desktop device.

Next: The sed commands might need some more tinkering as they're also erroring - it seems there may not be an easy "universal" version of the commands as I initially thought there would be.

I cloned the Repo, changed the Hostname in the Caddyfile and the templates/horizon.conf, and tried running the ./bin/init_dev.sh

The hostname modifications were intended to be run after init_dev.sh, by the way.

nikspyratos commented 11 months ago

Laravel requires these extensions by default:

cURL
DOM
Fileinfo
Filter
Hash
Mbstring
OpenSSL
PCRE
PDO
Session
Tokenizer
XML

I had a look around for tools to determine required extensions, and I got this longer list (have removed some I definitely don't think are necessary for local dev):

bcmath
ctype
curl
dba
dom
fileinfo
filter
gd
gettext
gmp
iconv
intl
libxml
mbstring
mysqli
openssl
pcntl
PDO
Phar
posix
redis
session
soap
sockets
tokenizer
zlib
thephilluk commented 11 months ago

Hi, got it working by installing the php8.2-intl extension. got it to display the page now.

however it seems that by default no "admin" role is created.

code@Mailcow:~/vscode/test/toybox$ php artisan app:create-admin-user

 ┌ What is your name? ──────────────────────────────────────────┐
 │ [NAME]                                                      │
 └──────────────────────────────────────────────────────────────┘

 ┌ What is your email? ─────────────────────────────────────────┐
 │ [EMAIL]                                        │
 └──────────────────────────────────────────────────────────────┘

 ┌ What is your password? ──────────────────────────────────────┐
 │ •••••••••••                                                  │
 └──────────────────────────────────────────────────────────────┘

   Spatie\Permission\Exceptions\RoleDoesNotExist 

  There is no role named `admin`.

  at vendor/spatie/laravel-permission/src/Exceptions/RoleDoesNotExist.php:11
      7▕ class RoleDoesNotExist extends InvalidArgumentException
      8▕ {
      9▕     public static function named(string $roleName)
     10▕     {
  ➜  11▕         return new static("There is no role named `{$roleName}`.");
     12▕     }
     13▕ 
     14▕     public static function withId(int $roleId)
     15▕     {

      +5 vendor frames 

  6   app/Console/Commands/CreateAdminUser.php:50
      App\Models\User::assignRole()
      +12 vendor frames 

  19  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

code@Mailcow:~/vscode/test/toybox$ php artisan migrate

   INFO  Nothing to migrate. 
nikspyratos commented 11 months ago

Interesting. init_dev.sh does run migrate --seed, which will call the RoleSeeder, so not sure why you don't have the role. Or it might be a connection issue of some kind.

I'll have to try it myself on a fresh copy, but for now what you can do is php artisan db:seed --class=RoleSeeder and then retry php artisan app:create-admin-user.

thephilluk commented 11 months ago

That seems to have worked. Thank you so much!

closed

nikspyratos commented 11 months ago

Best of luck, keep me posted how it goes!

nikspyratos commented 11 months ago

According to this and some light testing of the idea on my local and an Ubuntu instance, using sed -i.bak instead of sed -i '.bak' should work on both Linux and macOS. 72338ba22721a0cbd82c801002caefac91de853d contains this as a fix, so new installs shouldn't have the same issue.

I've also added some notes on extensions in f8224a52f2c258186e48e1514e3eabc27ed88e1e.