Laravel Sail failed to run artisan migrate - php

I have successfully install Laravel with Sail, the app is just fine, I can run it using sail up. however I am unable to migrate the database, everytime I run sail artisan migrate the following error thrown.
There is no existing directory at "/home/dariel/www/2021/nsmart/storage/logs" and it could not be created: Permission denied
at vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:172
168▕ set_error_handler([$this, 'customErrorHandler']);
169▕ $status = mkdir($dir, 0777, true);
170▕ restore_error_handler();
171▕ if (false === $status && !is_dir($dir)) {
➜ 172▕ throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and it could not be created: '.$this->errorMessage, $dir));
173▕ }
174▕ }
175▕ $this->dirCreated = true;
176▕ }
+10 vendor frames
11 [internal]:0
Illuminate\Foundation\Bootstrap\HandleExceptions::handleException()
I am stuck at this point, any help would be appreciated. thanks in advance.

You can try this
php artisan route:clear;
php artisan config:clear;
php artisan cache:clear;
sail artisan migrate;

As the error states: There is no existing directory at /home/dariel/www/2021/nsmart/storage/logs Permission denied. So you have to run mkdir /home/dariel/www/2021/nsmart/storage/logs and done...
Remember to have storage folder accesible for the process running your artisan command, it needs to use any folder inside storage.
And, if I am not wrong, sail up will give you an error, so that is why it is trying to do something in the logs folder.

Related

Unable to write file at location: to://app.js (Laravel 9 composer update on staging site)

So I just ran a composer updater on a staging site for an app I'm working on and i get this error after composer has generated it's package manifest:
> #php artisan vendor:publish --tag=laravel-assets --ansi --force
League\Flysystem\UnableToWriteFile
Unable to write file at location: to://app.js.
at vendor/league/flysystem/src/UnableToWriteFile.php:24
20▕ private $reason;
21▕
22▕ public static function atLocation(string $location, string $reason = '', Throwable $previous = null): UnableToWriteFile
23▕ {
➜ 24▕ $e = new static(rtrim("Unable to write file at location: {$location}. {$reason}"), 0, $previous);
25▕ $e->location = $location;
26▕ $e->reason = $reason;
27▕
28▕ return $e;
+24 vendor frames
25 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
Script #php artisan vendor:publish --tag=laravel-assets --ansi --force handling the post-update-cmd event returned with error code 1
I tried to rebuild the symbolic links with php artisan storage:link which was successful but still have the same error. I have also ran npm run dev and this finished too and created app.js (in public/js/ along with my other js files for this project). I have also just ran php artisan vendor:publish --tag=laravel-assets --ansi --force and as I expected I get the same error.
I assume this needs to be resolved for everything to work right despite it appearing to be correct? So what would I need to do to remove this error?
thanks
I had a similar issue with Sail/Docker,
I've fixed it by changing the ownership of the folder ./vendor and ./public/vendor to my user
In my WSL connexion and my project folder, I've ran:
sudo chown -R $USER:$USER ./vendor/ ./public/vendor

How do I solve a php artisan make:auth error?

I'm new to Laravel and I tried to use php artisan make:auth. But I keep getting a permission denied error. What exactly is wrong and how do I resolve this?
UnexpectedValueException
The stream or file "C:\Windows\System32\vfyp\storage\logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied
at C:\Windows\System32\vfyp\vendor\monolog\monolog\src\Monolog\Handler\StreamHandler.php:146
142▕ restore_error_handler();
143▕ if (!is_resource($stream)) {
144▕ $this->stream = null;
145▕
146▕ throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $url));
147▕ }
148▕ stream_set_chunk_size($stream, $this->streamChunkSize);
149▕ $this->stream = $stream;
150▕ }
C:\Windows\System32\vfyp\vendor\monolog\monolog\src\Monolog\Handler\AbstractProcessingHandler.php:48
Monolog\Handler\StreamHandler::write()
C:\Windows\System32\vfyp\vendor\monolog\monolog\src\Monolog\Logger.php:327
Monolog\Handler\AbstractProcessingHandler::handle()
I think in Laravel 8 php artisan make: auth will not work. For laravel 8 you have to use Laravel Jetstream (built-in with version 8) and Fortify package for default authentication. But if you are using Laravel 6 or 7 version . you have to use the following commands
composer require laravel/ui:^2.4
php artisan ui vue --auth
for more details, you can check Laravel Official Documentation -> Security->Authentication

Not able to generate php artisan key after copying .env file

i had unextracted a project file from git and i want to use it in the local server but when i copy paste the .env and run the command to generate the key. their seems to be an error.
i tried installing auto-dumpload command but it doesnt seem to work
php artisan key:generate
ErrorException :
file_get_contents(C:\Users\Anifz\React\getfyt-webapp-master.env):
failed to open stream: No such file or directory
at
C:\Users\Anifz\React\getfyt-webapp-master\vendor\laravel\framework\src\Illuminate\Foundation\Console\KeyGenerateCommand.php:96
92| {
93| file_put_contents($this->laravel->environmentFilePath(), preg_replace(
94| $this->keyReplacementPattern(),
95| 'APP_KEY='.$key,
96| file_get_contents($this->laravel->environmentFilePath())
97| ));
98| }
99|
100| /**
Exception trace:
1
file_get_contents("C:\Users\Anifz\React\getfyt-webapp-master.env")
C:\Users\Anifz\React\getfyt-webapp-master\vendor\laravel\framework\src\Illuminate\Foundation\Console\KeyGenerateCommand.php:96
2
Illuminate\Foundation\Console\KeyGenerateCommand::writeNewEnvironmentFileWith("base64:psZqTYKIKLRKPOhzVWUWZ2pny7A/nb4ArWeklrKWofE=")
C:\Users\Anifz\React\getfyt-webapp-master\vendor\laravel\framework\src\Illuminate\Foundation\Console\KeyGenerateCommand.php:80
Please use the argument -v to see more details.
The Following are the steps that you should follow -
extract the project.
copy .env.example to .env
run composer install
then run php artisan key:generate
I think .env file not exist ,if exist file copy one from .env.examle and set name as .env
Exec this code
php artisan key:generate
Maybe u want clear cache if want it u can with below code
php artisan cache:clear

ErrorException + unlink + Resource temporarily unavailable + Laravel 5.5

I'm a newbie in Laravel World. I've downloaded a project from gitlab.com and tried several time to run that project in my laptop.
In that project I've 6 migration files:
users_table
password_resets
posts_table
comments_table
profiles_table
categories_table
When executing php artisan db:seed command I'm getting the following error:
C:\xampp\htdocs\photoblog-master\photoblog-master>php artisan db:seed
Seeding: UserTableSeeder
[ErrorException]
unlink(C:\xampp\htdocs\photoblog-master\photoblog-master\public\uploads/user-picture\61224db90375756038856cd51e1c48a7.jpg): Resource temporarily unavailable
Would you please tell me how can I solve this error?
Is the file C:\xampp\htdocs\photoblog-master\photoblog-master\public\uploads/user-picture\61224db90375756038856cd51e1c48a7.jpg in use?
I have a similar issue when I opened a file and tried to delete it without fclose it first.

Lumen (Laravel): "Access denied for user 'forge'#'localhost'" when running "php artisan migrate:install"

Running through a Lumen tutorial that was written a year ago and several versions prior to the latest version of Lumen.
I've created an .env file which contains MySQL credentials for my project however when I attempt to run this:
php artisan migrate:install
I'm met with the following error:
Access denied for user 'forge'#'localhost'
So it seems apparent after Googling that it's not picking up my custom .env (i.e. custom.env) file. In the tutorial, it advises to uncomment this:
Dotenv::load(__DIR__.'/../');
From bootstrap/app.php however that line doesn't exist. There is however a try statement that looks like this:
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}
but it's uncommented and active. My custom .env is in the project root directory - same location as .env.example - and named custom.env.
What am I doing wrong?
RTM
It states in Lumen documentation (https://lumen.laravel.com/docs/5.2/configuration#environment-configuration):
"You should rename the .env.example file to .env when creating your application."
I named my custom .env file custom.env. It only needed to be .env.
Ran php artisan migrate:install and the migration table was created successfully.

Categories