#Installing Sail

1 messages · Page 1 of 1 (latest)

golden linden
#

Hello, I don't have much experience with setting up enviroments, less with ubuntu or linux. So any help would be welcome.

Here is what I've done so far:

  • Installed Docker Desktop and setup WSL2 by running wsl --update and wsl --set-default-version 2
  • Installed Ubuntu and configured it according to the following tutorial

Someone was helping me out on #sail , they gave me this link to follow https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#5-install-and-use-a-gui-package and I did all the steps except 5 because it doesn't seem necessary

  • Enabled it in Docker Desktop
    After that I went to Docker Desktop -> Settings -> Resources -> WSL Integration and enabled the ubuntu I just added with the tutorial above, hit Apply & Restart.

I'm currently a bit stuck here as to what the next step is, I need to make this work with some existing projects.
Currently I have my projects code in C:/www, I know that not ideal for Sail but where is it supposed to go? What should I do next?

If I look at the docs they seem to skip all these steps for the setting up https://laravel.com/docs/9.x/sail and go straight into the code but I'm not sure.

Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.

Ubuntu

Ubuntu is an open source software operating system that runs from the desktop, to the cloud, to all your internet connected things.

golden linden
#

I want to do it with existing projects

#

yea, its on BitBucket

#

ok, I'm trying to create a directory in /home but it says permission denied

#

like this?

#

its empty

#

ok, I'm getting this [email protected]: Permission denied (publickey). fatal: Could not read from remote repository.

#

I have ssh keys in C:/Users/Programador/.ssh

#

ok ill try to fix this and come back after I have my project cloned

steady nebula
golden linden
steady nebula
golden linden
#

in my case they're existing projects but without sail installed previously

#

should I still use the second link you provided?

steady nebula
#

Yeah, so probably something like this

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd):/var/www/html" \
    -w /var/www/html \
    laravelsail/php82-composer:latest \
    composer install --ignore-platform-reqs && composer require laravel/sail --dev && php artisan sail:install

Then you can do sail up

#

(haven't tried that, but that just seems logical)

golden linden
# steady nebula Yeah, so probably something like this ```sh docker run --rm \ -u "$(id -u):$...

I tried this and got the following error

 Illuminate\Database\QueryException

  could not find driver (SQL: select * from information_schema.tables where table_schema = forge and table_name = sp_apps and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703
    699▕         // If an exception occurs when attempting to run a query, we'll format the error
    700▕         // message to include the bindings with SQL, which will make this exception a
    701▕         // lot more helpful to the developer instead of just the database's errors.
    702▕         catch (Exception $e) {
  ➜ 703▕             throw new QueryException(
    704▕                 $query, $this->prepareBindings($bindings), $e
    705▕             );
    706▕         }
    707▕     }

  1   [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\AppServiceProvider))

      +15 vendor frames
  17  app/Providers/AppServiceProvider.php:42
      Illuminate\Support\Facades\Facade::__callStatic("hasTable")
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
steady nebula
golden linden
#

in this case should I run the migrations first?

steady nebula
#

Yeah, and like I said, it's a bad place to do that there, because that basically means your app won't work with Octane. You'd also run into a ton of issues, because if the database doesn't exist you can't install composer dependencies, like you're seeing now. You'd have to run it without scripts, then run the migrations (if that even works, because there is no data so it'll fail at booting your Laravel app) and then run composer install again to properly register all discovered packages

golden linden
#

I don't use Octane as far as I know (unless I need if for sail), this project is already in production on the servers, so I know it works. Is there a way I could run the commands separate, so I can run php artisan migrate before composer install?

#

This project does need a rework so I'll def consider moving that code some place else

steady nebula
#

I don't use Octane as far as I know
I just mean, it would prevent you from using Octane, or if you ever decide to use Octane it can introduce strange bugs.
Is there a way I could run the commands separate, so I can run php artisan migrate before composer install?
You need the composer dependencies to be installed before you can run migrate. Like I said, you'd have to install your dependencies without scripts; https://getcomposer.org/doc/03-cli.md#global-options, then migrate and then install it with the scripts I guess.

golden linden
#

kind of a hack way, what if I comment the code out that reads the db and then install, and uncomment it back and install again?

steady nebula
#

also kind of a hack way

golden linden
#

I'm setting up my env, how do I know which is the db user?

golden linden
# steady nebula also kind of a hack way

I comment it out and ran

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd):/var/www/html" \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs && composer require laravel/sail --dev && php artisan sail:install

Which worked and showed this at the end

How do I configure the database?

golden linden
#

but I don't see the docker-compose.yml anywhere in my project

#

composer install --ignore-platform-reqs seems to fail with

 @php artisan package:discover --ansi

   Error

  Class 'Composer\InstalledVersions' not found

  at vendor/maatwebsite/excel/src/Cache/CacheManager.php:43
     39▕      * @return MemoryCache
     40▕      */
     41▕     public function createMemoryDriver(): CacheInterface
     42▕     {
  ➜  43▕         if (!InstalledVersions::satisfies(new VersionParser, 'psr/simple-cache', '^3.0')) {
     44▕             return new MemoryCacheDeprecated(
     45▕                 config('excel.cache.batch.memory_limit', 60000)
     46▕             );
     47▕         }

      +11 vendor frames
  12  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
steady nebula
steady nebula
#

Fix your service provider I guess 🤷‍♂️

#

Or just what I mentioned earlier and not migrate. Guess you can add Sail and then manually register it so you're not dependent on auto discovery

golden linden
steady nebula
#

Yeah I guess. But then again, you don't have a database yet

golden linden
steady nebula
#

Or you can just temporarily disable that incorrect service provider and move on?

golden linden
steady nebula
#

Why don't you just try..

golden linden
#

I don't know where to disable it

steady nebula
#

Honestly this feels like holding hands, I'm not your senior that can guide you through all the steps

golden linden
#

I'm sorry, really for all my dumb questions

#

im the only person on my team that is going to use sail

#

so I can't ask anyone

steady nebula
#

Surely you have colleagues that know what service providers are

golden linden
#

i'm sorry, I disabled it completely and ran the original commands, it says Updating dependencies right now

#

It's giving me php extension errors. I'm going to install all the entensions I need and try again

golden linden
#

I'm now getting this

- requires php >=8.1 -> your PHP version (7.4.3-4ubuntu2.19) overridden by "config.platform.php" version (7.3.0) does not satisfy that requirement.

So I'l be trying to update my php to 8.1

steady nebula
#

I seriously have no clue what you're doing anymore. You were using the laravelsail/php81 container and now suddenly you've jumped back down to php 7.4...?

golden linden
#

all I'm doing is running these commands

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd):/var/www/html" \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs && composer require laravel/sail --dev && php artisan sail:install

I have no idea where the 7.4 came from

steady nebula
#

Guess those the && statements are executed on the host, might want to run that docker stuff one-by-one (it was just an example, I don't use Sail at all myself)

golden linden
#

maybe it was this other comment

you need to install composer before that sudo apt install composer, sail is not installed yet
and then run composer install --ignore-platform-reqs && composer require laravel/sail --dev && php artisan sail:install again

I did try that, and ran sudo apt install composer so maybe that's where the 7.4 is from, I'm not sure

golden linden
golden linden
#

I got it to run and again it worked I think but shows this at the bottom

#

How do I get the composer stuff to install?

#

Last ubuntu I had did the same thing, and I ran the recommended command there but after that I got a php version mismatch error which I didn't know what to do about so I uninstalled Ubuntu and here I am trying again

#

I was told that Sail is great for different php versions and all that but I can't even seem to set that up anywhere, I don't see the docker file or anything

golden linden
#

What now?

hybrid notch
#

which mean you should run the command separately

#

without the &&

#

docker .... composer install

#

docker ...... composer require laravel/sail --dev

tawny herald
#

why are you using docker run with sail ?

#

sail is supposed to handle everything

#

also sail is meant for dev not prods

golden linden
#

I'm just trying to replace Homestead with something else, when I asked everyone recommended Sail that's why I'm trying to set it up

golden linden
hybrid notch
golden linden
hybrid notch
#

but php is require

golden linden
#

ok I tried that without the && and no errors but how can I confirm everything is installed?

tawny herald
#

./vendor/bin/sail up

golden linden
#

now it doesn't show the composer not found message

#

ok

#

no configuration file provided: not found

#

I don't see any aditional config files in my project

tawny herald
#

not even at the root ?

golden linden
#

nope

hybrid notch
golden linden
#

Like this?

docker container run --rm -v $(pwd):/app/ php:8.1-cli composer install ??

#

if I did want to have it locally similar to Homestead where I could cd into the project directory and run like composer install commands or php artisan commands what should I do? Is that possible?

tawny herald
#

it might be better to start with a fresh laravel app with sail

#

and slowly move things over

golden linden
#

I can't do that, this is in production already

#

what I can do is maybe get a teammate to install Sail on the project and upload that, so I can clone it but idk if that would work

golden linden
#

I found out that sail is already installed, but my teammate tried php artisan sail:install and got a bunch of errors, probably bc he doesn't use docker/sail and uses homestead but ig now I still need to run that command php artisan sail:install how can i do that??

golden linden