Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abass's avatar

Homestead/Vagrant Cant Change Storage File Permissions Issue

I just switched over all of my projects to a new directory in my system and now I'm having problems getting the proper file permissions. Currently have the error:

file_put_contents(/home/vagrant/project/storage/framework/services.json): failed to open stream: Permission denied

When I homestead ssh in and try to sudo chmod -R 777 storage it just doesn't work. It doesn't change the directory at all.

I was reading around and people were suggesting to use the following code and to put it in the Vagrantfile but I can't figure it out:

group: "sync_group", owner: "sync_owner", mount_options: ['dmode=777, fmode=776']

Would that go in user/Homestead/Vagrantfile? and where do I even put it within this:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

Any help is greatly appreciated. So frustrated, just want to continue working on client projects. I am on Windows 10 btw, not sure if that matters at all but it seems to be the root of many problems .

0 likes
2 replies
abass's avatar
abass
OP
Best Answer
Level 1

Alright, so I'm using Windows and I was trying to set chmod 777 inside of the virtual machine instead of just on the host. (I was doing homestead ssh then chmod -R 777 storage). Simply doing it on the host machine instead of the virtual machine fixed it.

2 likes

Please or to participate in this conversation.